kopia lustrzana https://github.com/wagtail/wagtail
Extract BaseListingView.get_filterset_kwargs()
rodzic
88fad9a071
commit
baf26ed5fa
|
@ -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)
|
||||
|
|
Ładowanie…
Reference in New Issue