Skip to content

Commit c70eba4

Browse files
Merge pull request #51 from zulrang/zulrang-patch-drf38
Fix compatibility with djangorestframework>=3.8.0
2 parents f1b3918 + ed6370d commit c70eba4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/django_elasticsearch_dsl_drf/pagination.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from django.core import paginator as django_paginator
1111

1212
from rest_framework import pagination
13-
from rest_framework.pagination import _get_count
1413
from rest_framework.exceptions import NotFound
1514
from rest_framework.response import Response
1615

@@ -208,7 +207,11 @@ def paginate_queryset(self, queryset, request, view=None):
208207
if is_suggest:
209208
return queryset.execute_suggest().to_dict()
210209

211-
self.count = _get_count(queryset)
210+
if hasattr(self, 'get_count'):
211+
self.count = self.get_count(queryset)
212+
else:
213+
from rest_framework.pagination import _get_count
214+
self.count = _get_count(queryset)
212215
self.limit = self.get_limit(request)
213216
if self.limit is None:
214217
return None

0 commit comments

Comments
 (0)