summaryrefslogtreecommitdiff
path: root/django/core/paginator.py
diff options
context:
space:
mode:
authorAndrew Jesaitis <andrew@andrewjesaitis.com>2013-03-18 14:29:37 -0600
committerClaude Paroz <claude@2xlibre.net>2013-05-25 16:27:26 +0200
commit31f6421b134e4e83a459d2faa1009b33fefd6276 (patch)
tree60c56f3665a64c574fac1c908e26b890355ed6ca /django/core/paginator.py
parent2ee447fb5f8974b432d3dd421af9a242215aea44 (diff)
Fixed #19938 -- Consumed iterator only once in paginator's Page
Thanks Joshua Fialkoff for the report.
Diffstat (limited to 'django/core/paginator.py')
-rw-r--r--django/core/paginator.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/django/core/paginator.py b/django/core/paginator.py
index 9ccff51a34..c8b9377856 100644
--- a/django/core/paginator.py
+++ b/django/core/paginator.py
@@ -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