Skip to content

Commit

Permalink
docs: add documentation regarding filterset_factory
Browse files Browse the repository at this point in the history
  • Loading branch information
b1rger committed Jan 24, 2024
1 parent e8a5d1f commit 4fed365
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/ref/filterset.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,22 @@ filters for a model field, you can override ``filter_for_lookup()``. Ex::

# use default behavior otherwise
return super().filter_for_lookup(f, lookup_type)


.. _filterset_factory:

Using ``filterset_factory``
---------------------------

A ``FilterSet`` for a ``model`` can also be created by the
``filterset_factory``, which creats a ``FilterSet`` with the ``model`` set in
the FilterSets Meta. You can pass a customized ``FilterSet`` class to the
``filterset_factory``, which then uses this class a a base for the created
``FilterSet``. Ex::

class CustomFilterSet(django_filters.FilterSet):
class Meta:
form = CustomFilterSetForm


filterset = filterset_factory(Product, filterset=CustomFilterSet)

0 comments on commit 4fed365

Please sign in to comment.