From 6e3d75f0ab5bae710e0dcd1286b7e13a6572ece5 Mon Sep 17 00:00:00 2001 From: Sage Abdullah Date: Mon, 20 Mar 2023 17:00:00 +0000 Subject: [PATCH] Allow IndexView.list_filter to be set via SnippetViewSet.list_filter --- wagtail/snippets/views/snippets.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wagtail/snippets/views/snippets.py b/wagtail/snippets/views/snippets.py index 8ad7739036..d1352bec00 100644 --- a/wagtail/snippets/views/snippets.py +++ b/wagtail/snippets/views/snippets.py @@ -608,6 +608,12 @@ class SnippetViewSet(ViewSet): #: If left unset, the ``list_display`` attribute of the index view will be used instead, which by default is defined as ``["__str__", wagtail.admin.ui.tables.UpdatedAtColumn()]``. list_display = None + #: A list or tuple, where each item is the name of model fields of type ``BooleanField``, ``CharField``, ``DateField``, ``DateTimeField``, ``IntegerField`` or ``ForeignKey``. + #: Alternatively, it can also be a dictionary that maps a field name to a list of lookup expressions. + #: This will be passed as django-filter's ``FilterSet.Meta.fields`` attribute. See `its documentation `_ for more details. + #: If ``filterset_class`` is set, this attribute will be ignored. + list_filter = None + #: The number of items to display per page in the index view. Defaults to 20. list_per_page = 20 @@ -751,6 +757,7 @@ class SnippetViewSet(ViewSet): edit_url_name=self.get_url_name("edit"), delete_url_name=self.get_url_name("delete"), list_display=self.list_display, + list_filter=self.list_filter, paginate_by=self.list_per_page, ) @@ -768,6 +775,7 @@ class SnippetViewSet(ViewSet): edit_url_name=self.get_url_name("edit"), delete_url_name=self.get_url_name("delete"), list_display=self.list_display, + list_filter=self.list_filter, paginate_by=self.list_per_page, )