mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-04 20:40:14 +03:00
use position from page only when page is exist
This commit is contained in:
parent
d3cd207411
commit
f91d332c6c
|
@ -540,7 +540,7 @@ class CursorPagination(BasePagination):
|
|||
if not self.has_next:
|
||||
return None
|
||||
|
||||
if self.cursor and self.cursor.reverse and self.cursor.offset != 0:
|
||||
if self.cursor and self.cursor.reverse and self.cursor.offset != 0 and self.page:
|
||||
# If we're reversing direction and we have an offset cursor
|
||||
# then we cannot use the first position we find as a marker.
|
||||
compare = self._get_position_from_instance(self.page[-1], self.ordering)
|
||||
|
@ -588,7 +588,7 @@ class CursorPagination(BasePagination):
|
|||
if not self.has_previous:
|
||||
return None
|
||||
|
||||
if self.cursor and not self.cursor.reverse and self.cursor.offset != 0:
|
||||
if self.cursor and not self.cursor.reverse and self.cursor.offset != 0 and self.page:
|
||||
# If we're reversing direction and we have an offset cursor
|
||||
# then we cannot use the first position we find as a marker.
|
||||
compare = self._get_position_from_instance(self.page[0], self.ordering)
|
||||
|
|
Loading…
Reference in New Issue
Block a user