kopia lustrzana https://github.com/wagtail/wagtail
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
rodzic
9e36fa74b6
commit
c36b891e35
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
Ładowanie…
Reference in New Issue