Allow mutating the queryset

This commit is contained in:
Mark Veidemanis 2023-02-11 16:38:22 +00:00
parent bb5b473898
commit 04d41f7c97
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
1 changed files with 4 additions and 0 deletions

View File

@ -50,6 +50,9 @@ class ObjectList(RestrictedViewMixin, ObjectNameMixin, ListView):
delete_all_url_name = None delete_all_url_name = None
widget_options = None widget_options = None
def queryset_mutate(self, queryset):
pass
# copied from BaseListView # copied from BaseListView
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
type = kwargs.get("type", None) type = kwargs.get("type", None)
@ -60,6 +63,7 @@ class ObjectList(RestrictedViewMixin, ObjectNameMixin, ListView):
self.request = request self.request = request
self.object_list = self.get_queryset(**kwargs) self.object_list = self.get_queryset(**kwargs)
self.queryset_mutate(self.queryset)
if isinstance(self.object_list, HttpResponse): if isinstance(self.object_list, HttpResponse):
return self.object_list return self.object_list
if isinstance(self.object_list, HttpResponseBadRequest): if isinstance(self.object_list, HttpResponseBadRequest):