diff --git a/djangorestframework/mixins.py b/djangorestframework/mixins.py index 15d7faf0e..c7f7b10cd 100644 --- a/djangorestframework/mixins.py +++ b/djangorestframework/mixins.py @@ -675,9 +675,7 @@ class ListModelMixin(ModelMixin): queryset = None def get(self, request, *args, **kwargs): - model = self.resource.model - - queryset = self.queryset if self.queryset is not None else model.objects.all() + queryset = self.get_queryset() if hasattr(self, 'resource'): ordering = getattr(self.resource, 'ordering', None) @@ -689,6 +687,10 @@ class ListModelMixin(ModelMixin): queryset = queryset.order_by(*args) return queryset.filter(self.build_query(**kwargs)) + def get_queryset(self): + model = self.resource.model + return model.objects.all() if self.queryset is None else self.queryset + ########## Pagination Mixins ##########