Replace IndexView.get_filterset_class with filterset_class cached property

This is now possible thanks to ViewSet.UNDEFINED. Previously, we would
be getting the unbound cached property instance from the view class,
only to pass it back to the view during as_view() – which results in a
broken state.
pull/12236/head
Sage Abdullah 2024-08-15 12:55:15 +01:00
rodzic 9e36fa74b6
commit c36b891e35
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EB1A33CC51CC0217
2 zmienionych plików z 3 dodań i 7 usunięć
wagtail/admin
views/generic
viewsets

Wyświetl plik

@ -85,11 +85,6 @@ class IndexView(
def setup(self, request, *args, **kwargs):
super().setup(request, *args, **kwargs)
if not self.filterset_class:
# Allow filterset_class to be dynamically constructed from list_filter
self.filterset_class = self.get_filterset_class()
self.setup_search()
def setup_search(self):
@ -124,7 +119,8 @@ class IndexView(
return SearchForm()
def get_filterset_class(self):
@cached_property
def filterset_class(self):
# Allow filterset_class to be dynamically constructed from list_filter.
# If the model is translatable, ensure a ``WagtailFilterSet`` subclass

Wyświetl plik

@ -468,7 +468,7 @@ class ModelViewSet(ViewSet):
subclass of `django_filters.FilterSet <https://django-filter.readthedocs.io/en/stable/ref/filterset.html>`_.
This will be passed to the ``filterset_class`` attribute of the index view.
"""
return self.index_view_class.filterset_class
return self.UNDEFINED
@cached_property
def search_fields(self):