mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-03 05:04:31 +03:00
page_size needs to be stored as state on CursorPagination. Refs 3147.
This commit is contained in:
parent
0ea64f6b33
commit
c879aaf398
|
@ -455,8 +455,8 @@ class CursorPagination(BasePagination):
|
||||||
template = 'rest_framework/pagination/previous_and_next.html'
|
template = 'rest_framework/pagination/previous_and_next.html'
|
||||||
|
|
||||||
def paginate_queryset(self, queryset, request, view=None):
|
def paginate_queryset(self, queryset, request, view=None):
|
||||||
page_size = self.get_page_size(request)
|
self.page_size = self.get_page_size(request)
|
||||||
if not page_size:
|
if not self.page_size:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
self.base_url = request.build_absolute_uri()
|
self.base_url = request.build_absolute_uri()
|
||||||
|
@ -491,8 +491,8 @@ class CursorPagination(BasePagination):
|
||||||
# If we have an offset cursor then offset the entire page by that amount.
|
# If we have an offset cursor then offset the entire page by that amount.
|
||||||
# We also always fetch an extra item in order to determine if there is a
|
# We also always fetch an extra item in order to determine if there is a
|
||||||
# page following on from this one.
|
# page following on from this one.
|
||||||
results = list(queryset[offset:offset + page_size + 1])
|
results = list(queryset[offset:offset + self.page_size + 1])
|
||||||
self.page = list(results[:page_size])
|
self.page = list(results[:self.page_size])
|
||||||
|
|
||||||
# Determine the position of the final item following the page.
|
# Determine the position of the final item following the page.
|
||||||
if len(results) > len(self.page):
|
if len(results) > len(self.page):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user