mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-12-02 22:44:08 +03:00
Handle a callable queryset in ModelMixin
To allow queryset's that may depend on a value obtained from a middleware or somewhere else that can change the result of the query, accept and process a callable queryset in addition to previous behavior.
This commit is contained in:
parent
55317b0372
commit
02b2020995
|
@ -3,6 +3,7 @@ The :mod:`mixins` module provides a set of reusable `mixin`
|
|||
classes that can be added to a `View`.
|
||||
"""
|
||||
|
||||
from collections import Callable
|
||||
from django.contrib.auth.models import AnonymousUser
|
||||
from django.core.paginator import Paginator
|
||||
from django.db.models.fields.related import ForeignKey
|
||||
|
@ -513,6 +514,8 @@ class ModelMixin(object):
|
|||
"""
|
||||
Return the queryset for this view.
|
||||
"""
|
||||
queryset = getattr(self.resource, 'queryset',
|
||||
self.resource.model.objects.all())
|
||||
return getattr(self.resource, 'queryset',
|
||||
self.resource.model.objects.all())
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user