django-filter 0,-1,3,1,3,0,4 travis-ci python

A generic system for filtering Django QuerySets based on user selections

2 years after

Django Filter

Django-filter is a reusable Django application allowing users to declaratively add dynamic QuerySet filtering from URL parameters.

Full documentation on read the docs_.

.. image:: :target:

.. image:: :target:

.. image:: :target:


  • Python: 2.7, 3.3, 3.4, 3.5
  • Django: 1.8, 1.9, 1.10, 1.11
  • DRF: 3.5


Install using pip:

.. code-block:: sh

pip install django-filter

Then add 'django_filters' to your INSTALLED_APPS.

.. code-block:: python



Django-filter can be used for generating interfaces similar to the Django admin's list_filter interface. It has an API very similar to Django's ModelForms. For example, if you had a Product model you could have a filterset for it with the code:

.. code-block:: python

import django_filters

class ProductFilter(django_filters.FilterSet):
    class Meta:
        model = Product
        fields = ['name', 'price', 'manufacturer']

And then in your view you could do:

.. code-block:: python

def product_list(request):
    filter = ProductFilter(request.GET, queryset=Product.objects.all())
    return render(request, 'my_app/template.html', {'filter': filter})

Usage with Django REST Framework

Django-filter provides a custom FilterSet and filter backend for use with Django REST Framework.

To use this adjust your import to use django_filters.rest_framework.FilterSet.

.. code-block:: python

from django_filters import rest_framework as filters

class ProductFilter(filters.FilterSet):
    class Meta:
        model = Product
        fields = ('category', 'in_stock')

For more details see the DRF integration docs_.


If you have questions about usage or development you can join the mailing list_.

.. read the docs: .. mailing list: .. _DRF integration docs:

Related Repositories



django-filter meets django-pagination ...



Help command which generate default filter class by provided model for django-fi ...

Top Contributors

carltongibson rpkilby alex apollo13 nkryptic blueyed bogdal tomchristie ad-m benkonrath alej0varas xordoquy nicholasserra thedrow whitews thenewguy alasdairnicol edmorley patriotyk augonis JonPeel evildmp jezdez eosrei shanx qrilka vladimirbright cevaris zoidbergwill ticosax


-   v0.13 zip tar
-   v0.10.0 zip tar
-   v0.9.2 zip tar
-   v0.8 zip tar
-   v0.7 zip tar
-   v0.6 zip tar
-   v0.6a1 zip tar
-   mc2 zip tar
-   0.15.2 zip tar
-   0.15.1 zip tar
-   0.15.0 zip tar
-   0.14.0 zip tar
-   0.12.0 zip tar
-   0.11.0 zip tar
-   0.10.0mc zip tar
-   0.9.1 zip tar
-   0.9.0 zip tar
-   0.5.4 zip tar
-   0.5.3 zip tar
-   0.5.2 zip tar
-   0.5.1 zip tar
-   0.5.0 zip tar
-   0.2.0 zip tar
-   0.1.0 zip tar