1
0
mirror of https://github.com/django/django.git synced 2025-10-27 15:46:10 +00:00

Fixed #19938 -- Consumed iterator only once in paginator's Page

Thanks Joshua Fialkoff for the report.
This commit is contained in:
Andrew Jesaitis
2013-03-18 14:29:37 -06:00
committed by Claude Paroz
parent 2ee447fb5f
commit 31f6421b13
2 changed files with 6 additions and 1 deletions

View File

@@ -121,7 +121,9 @@ class Page(collections.Sequence):
raise TypeError
# The object_list is converted to a list so that if it was a QuerySet
# it won't be a database hit per __getitem__.
return list(self.object_list)[index]
if not isinstance(self.object_list, list):
self.object_list = list(self.object_list)
return self.object_list[index]
def has_next(self):
return self.number < self.paginator.num_pages