From 4fed365469946f5851a98fca896ba10768682698 Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Wed, 24 Jan 2024 16:36:37 +0100 Subject: [PATCH] docs: add documentation regarding filterset_factory --- docs/ref/filterset.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/ref/filterset.txt b/docs/ref/filterset.txt index 139f4190..ecc9e558 100644 --- a/docs/ref/filterset.txt +++ b/docs/ref/filterset.txt @@ -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)