django-filtrate


Namedjango-filtrate JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/Lenders-Cooperative/django-filtrate
SummaryCustomizable Django Admin filters
upload_time2023-02-06 04:46:21
maintainer
docs_urlNone
authorLenders-Cooperative
requires_python
licenseBSD
keywords django-filtrate
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =============================
Django Filtrate
=============================

.. image:: https://img.shields.io/badge/license-BSD-blue.svg
   :target: https://github.com/Lenders-Cooperative/django-filtrate/blob/main/LICENSE

.. image:: https://img.shields.io/pypi/v/django-filtrate.svg
   :target: https://pypi.org/project/django-filtrate/

.. image:: https://img.shields.io/pypi/pyversions/django-filtrate
   :target: https://pypi.org/project/django-filtrate/

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
   :target: https://github.com/psf/black


Allow trusted users to create custom Django admin filters


Quickstart
----------

Install Django Filtrate::

    pip install django-filtrate

Add it to your ``INSTALLED_APPS``:

.. code-block:: python

    INSTALLED_APPS = (
        ...
        "filtrate",
        ...
    )

1) Add the mixin

.. code-block:: python

   class YourModelAdmin(FiltrateMixin, admin.ModelAdmin):
       ...


2) Navigate to http://localhost:8000/admin/filtrate/filter
3) Add your new filter!

How it works
------------
As soon as you add the FiltrateMixin to your ModelAdmin, your model and admin
will be registered with Filtrate.  At this point, you can navigate to the Filtrate
admin page, and begin adding filters.

Filtrate uses Django's built-in filtering to build it's ListFilters, by passing the `filters` field as arguments
to the queryset. See https://docs.djangoproject.com/en/dev/topics/db/queries/#retrieving-specific-objects-with-filters
for more details about filtering queries with Django.

For example, let's say you have the following `Template` model:

.. code-block:: python

  class Template(models.Model):
      name = models.CharField(max_length=25)
      is_active = models.BooleanField(default=True)
      created_at = models.DateTimeField(auto_now_add=True)

      def __str__(self):
          return self.name

If you wanted to build a filter for all active Templates created on or after 2023-01-01,
then your `Filter.filters` should look like:

.. code-block:: python

  {
      "is_active": True,
      "created_at__gte": "2023-01-01",
  }


Save it, and then voila, you have a new filter on your TemplateAdmin!

Happy Filtering!


Features
--------
* ``Filter`` data model
* ``FiltrateMixin`` ModelAdmin mixin


TODO's
-------
* User-specific filters
* Export data
* `Add Filter` button on changelist
* Additional test coverage
* Setup tox
* More documentation


Local Development
-----------------

::

    make install
    make test


Deployment
----------

::

    make build
    make deploy


License
-------

This project is provided under the `BSD License <https://github.com/Lenders-Cooperative/django-filtrate/blob/main/LICENSE>`_.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Lenders-Cooperative/django-filtrate",
    "name": "django-filtrate",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "django-filtrate",
    "author": "Lenders-Cooperative",
    "author_email": "dgraves@thesummitgrp.com",
    "download_url": "https://files.pythonhosted.org/packages/3f/4b/d39de6611a07f921e11eecbaa12f0b57d85132fc895014de3a1423ef246e/django-filtrate-0.1.1.tar.gz",
    "platform": null,
    "description": "=============================\nDjango Filtrate\n=============================\n\n.. image:: https://img.shields.io/badge/license-BSD-blue.svg\n   :target: https://github.com/Lenders-Cooperative/django-filtrate/blob/main/LICENSE\n\n.. image:: https://img.shields.io/pypi/v/django-filtrate.svg\n   :target: https://pypi.org/project/django-filtrate/\n\n.. image:: https://img.shields.io/pypi/pyversions/django-filtrate\n   :target: https://pypi.org/project/django-filtrate/\n\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n   :target: https://github.com/psf/black\n\n\nAllow trusted users to create custom Django admin filters\n\n\nQuickstart\n----------\n\nInstall Django Filtrate::\n\n    pip install django-filtrate\n\nAdd it to your ``INSTALLED_APPS``:\n\n.. code-block:: python\n\n    INSTALLED_APPS = (\n        ...\n        \"filtrate\",\n        ...\n    )\n\n1) Add the mixin\n\n.. code-block:: python\n\n   class YourModelAdmin(FiltrateMixin, admin.ModelAdmin):\n       ...\n\n\n2) Navigate to http://localhost:8000/admin/filtrate/filter\n3) Add your new filter!\n\nHow it works\n------------\nAs soon as you add the FiltrateMixin to your ModelAdmin, your model and admin\nwill be registered with Filtrate.  At this point, you can navigate to the Filtrate\nadmin page, and begin adding filters.\n\nFiltrate uses Django's built-in filtering to build it's ListFilters, by passing the `filters` field as arguments\nto the queryset. See https://docs.djangoproject.com/en/dev/topics/db/queries/#retrieving-specific-objects-with-filters\nfor more details about filtering queries with Django.\n\nFor example, let's say you have the following `Template` model:\n\n.. code-block:: python\n\n  class Template(models.Model):\n      name = models.CharField(max_length=25)\n      is_active = models.BooleanField(default=True)\n      created_at = models.DateTimeField(auto_now_add=True)\n\n      def __str__(self):\n          return self.name\n\nIf you wanted to build a filter for all active Templates created on or after 2023-01-01,\nthen your `Filter.filters` should look like:\n\n.. code-block:: python\n\n  {\n      \"is_active\": True,\n      \"created_at__gte\": \"2023-01-01\",\n  }\n\n\nSave it, and then voila, you have a new filter on your TemplateAdmin!\n\nHappy Filtering!\n\n\nFeatures\n--------\n* ``Filter`` data model\n* ``FiltrateMixin`` ModelAdmin mixin\n\n\nTODO's\n-------\n* User-specific filters\n* Export data\n* `Add Filter` button on changelist\n* Additional test coverage\n* Setup tox\n* More documentation\n\n\nLocal Development\n-----------------\n\n::\n\n    make install\n    make test\n\n\nDeployment\n----------\n\n::\n\n    make build\n    make deploy\n\n\nLicense\n-------\n\nThis project is provided under the `BSD License <https://github.com/Lenders-Cooperative/django-filtrate/blob/main/LICENSE>`_.",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Customizable Django Admin filters",
    "version": "0.1.1",
    "split_keywords": [
        "django-filtrate"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3f4bd39de6611a07f921e11eecbaa12f0b57d85132fc895014de3a1423ef246e",
                "md5": "8c46414194fb93ddd8d47b0f1a60e224",
                "sha256": "dd42d8a07c13ae4e4dd3a3bcaf0b9e11b88d7f5e2c6518cefc6726e89d985a8a"
            },
            "downloads": -1,
            "filename": "django-filtrate-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "8c46414194fb93ddd8d47b0f1a60e224",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7562,
            "upload_time": "2023-02-06T04:46:21",
            "upload_time_iso_8601": "2023-02-06T04:46:21.533373Z",
            "url": "https://files.pythonhosted.org/packages/3f/4b/d39de6611a07f921e11eecbaa12f0b57d85132fc895014de3a1423ef246e/django-filtrate-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-02-06 04:46:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Lenders-Cooperative",
    "github_project": "django-filtrate",
    "lcname": "django-filtrate"
}
        
Elapsed time: 0.20191s