mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-29 09:30:07 +03:00
LimitOffsetPagination: Changed the check of data type to try-catch in get_count method to isinstance method
This commit is contained in:
parent
dffa612134
commit
9d980a9b8d
|
@ -8,6 +8,7 @@ from urllib import parse
|
||||||
|
|
||||||
from django.core.paginator import InvalidPage
|
from django.core.paginator import InvalidPage
|
||||||
from django.core.paginator import Paginator as DjangoPaginator
|
from django.core.paginator import Paginator as DjangoPaginator
|
||||||
|
from django.db.models.query import QuerySet
|
||||||
from django.template import loader
|
from django.template import loader
|
||||||
from django.utils.encoding import force_str
|
from django.utils.encoding import force_str
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
@ -522,9 +523,9 @@ class LimitOffsetPagination(BasePagination):
|
||||||
"""
|
"""
|
||||||
Determine an object count, supporting either querysets or regular lists.
|
Determine an object count, supporting either querysets or regular lists.
|
||||||
"""
|
"""
|
||||||
try:
|
if isinstance(queryset, QuerySet):
|
||||||
return queryset.count()
|
return queryset.count()
|
||||||
except (AttributeError, TypeError):
|
else:
|
||||||
return len(queryset)
|
return len(queryset)
|
||||||
|
|
||||||
def get_schema_fields(self, view):
|
def get_schema_fields(self, view):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user