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:
committed by
Claude Paroz
parent
2ee447fb5f
commit
31f6421b13
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user