summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRigel Di Scala <rigel.discala@propylon.com>2015-06-06 20:24:02 +0100
committerTim Graham <timograham@gmail.com>2015-07-03 11:34:34 -0400
commitb91a2a499fd562011fd275238924baa6002fb1f8 (patch)
treed6bd663e6a351b5b87f87223bf98b804026089a4 /docs
parentfd869cceacafdaf2c5865cc525f88357b6a26aad (diff)
Fixed #23190 -- Made Paginator.page_range an iterator
Diffstat (limited to 'docs')
-rw-r--r--docs/releases/1.9.txt13
-rw-r--r--docs/topics/pagination.txt10
2 files changed, 21 insertions, 2 deletions
diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt
index 0b84b3c6d3..75c126c38b 100644
--- a/docs/releases/1.9.txt
+++ b/docs/releases/1.9.txt
@@ -770,6 +770,19 @@ To fix your ``simple_tag``\s, it is best to apply the following practices:
Tags that follow these rules will be correct and safe whether they are run on
Django 1.9+ or earlier.
+``Paginator.page_range``
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+:attr:`Paginator.page_range <django.core.paginator.Paginator.page_range>` is
+now an iterator instead of a list.
+
+In versions of Django previous to 1.8, ``Paginator.page_range`` returned a
+``list`` in Python 2 and a ``range`` in Python 3. Django 1.8 consistently
+returned a list, but an iterator is more efficient.
+
+Existing code that depends on ``list`` specific features, such as indexing,
+can be ported by converting the iterator into a ``list`` using ``list()``.
+
Miscellaneous
~~~~~~~~~~~~~
diff --git a/docs/topics/pagination.txt b/docs/topics/pagination.txt
index 6ab12b2d1b..ee801ed620 100644
--- a/docs/topics/pagination.txt
+++ b/docs/topics/pagination.txt
@@ -24,8 +24,10 @@ page::
4
>>> p.num_pages
2
+ >>> type(p.page_range) # `<type 'rangeiterator'>` in Python 2.
+ <class 'range_iterator'>
>>> p.page_range
- [1, 2]
+ range(1, 3)
>>> page1 = p.page(1)
>>> page1
@@ -191,8 +193,12 @@ Attributes
.. attribute:: Paginator.page_range
- A 1-based range of page numbers, e.g., ``[1, 2, 3, 4]``.
+ A 1-based range iterator of page numbers, e.g. yielding ``[1, 2, 3, 4]``.
+ .. versionchanged:: 1.9
+
+ In older versions, ``page_range`` returned a list instead of an
+ iterator.
``InvalidPage`` exceptions
==========================