mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-09-16 17:22:32 +03:00
Merge c557d01793
into d88ae359b8
This commit is contained in:
commit
a6ed4b701d
|
@ -3,6 +3,7 @@ The :mod:`mixins` module provides a set of reusable `mixin`
|
||||||
classes that can be added to a `View`.
|
classes that can be added to a `View`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from collections import Callable
|
||||||
from django.contrib.auth.models import AnonymousUser
|
from django.contrib.auth.models import AnonymousUser
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from django.db.models.fields.related import ForeignKey
|
from django.db.models.fields.related import ForeignKey
|
||||||
|
@ -513,8 +514,10 @@ class ModelMixin(object):
|
||||||
"""
|
"""
|
||||||
Return the queryset for this view.
|
Return the queryset for this view.
|
||||||
"""
|
"""
|
||||||
return getattr(self.resource, 'queryset',
|
queryset = getattr(self.resource, 'queryset',
|
||||||
self.resource.model.objects.all())
|
self.resource.model.objects.all())
|
||||||
|
return queryset() if isinstance(queryset, Callable) else queryset
|
||||||
|
|
||||||
|
|
||||||
def get_ordering(self):
|
def get_ordering(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user