Extract BaseListingView.get_filterset_kwargs()

pull/11698/head
Sage Abdullah 2024-02-27 13:15:30 +00:00
rodzic 88fad9a071
commit baf26ed5fa
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EB1A33CC51CC0217
1 zmienionych plików z 7 dodań i 1 usunięć

Wyświetl plik

@ -201,7 +201,7 @@ class BaseListingView(WagtailAdminTemplateMixin, BaseListView):
@cached_property
def filters(self):
if self.filterset_class:
filterset = self.filterset_class(self.request.GET, request=self.request)
filterset = self.filterset_class(**self.get_filterset_kwargs())
# Don't use the filterset if it has no fields
if filterset.form.fields:
return filterset
@ -213,6 +213,12 @@ class BaseListingView(WagtailAdminTemplateMixin, BaseListView):
self.filters and self.filters.is_valid() and self.filters.form.has_changed()
)
def get_filterset_kwargs(self):
return {
"data": self.request.GET,
"request": self.request,
}
def filter_queryset(self, queryset):
if self.filters and self.filters.is_valid():
queryset = self.filters.filter_queryset(queryset)