use position from page only when page is exist

This commit is contained in:
homm 2015-07-13 18:50:25 +03:00
parent d3cd207411
commit f91d332c6c

View File

@ -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)