Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
b91a2a49
Kaydet (Commit)
b91a2a49
authored
Haz 06, 2015
tarafından
Rigel Di Scala
Kaydeden (comit)
Tim Graham
Tem 03, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #23190 -- Made Paginator.page_range an iterator
üst
fd869cce
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
3 deletions
+29
-3
AUTHORS
AUTHORS
+1
-0
paginator.py
django/core/paginator.py
+1
-1
1.9.txt
docs/releases/1.9.txt
+13
-0
pagination.txt
docs/topics/pagination.txt
+8
-2
tests.py
tests/pagination/tests.py
+6
-0
No files found.
AUTHORS
Dosyayı görüntüle @
b91a2a49
...
...
@@ -600,6 +600,7 @@ answer newbie questions, and generally made Django that much better:
Richard Davies <richard.davies@elastichosts.com>
Richard House <Richard.House@i-logue.com>
Rick Wagner <rwagner@physics.ucsd.edu>
Rigel Di Scala <rigel.discala@propylon.com>
Robert Coup
Robert Myers <myer0052@gmail.com>
Roberto Aguilar <roberto@baremetal.io>
...
...
django/core/paginator.py
Dosyayı görüntüle @
b91a2a49
...
...
@@ -96,7 +96,7 @@ class Paginator(object):
Returns a 1-based range of pages for iterating through within
a template for loop.
"""
return
list
(
six
.
moves
.
range
(
1
,
self
.
num_pages
+
1
)
)
return
six
.
moves
.
range
(
1
,
self
.
num_pages
+
1
)
page_range
=
property
(
_get_page_range
)
...
...
docs/releases/1.9.txt
Dosyayı görüntüle @
b91a2a49
...
...
@@ -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
~~~~~~~~~~~~~
...
...
docs/topics/pagination.txt
Dosyayı görüntüle @
b91a2a49
...
...
@@ -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
==========================
...
...
tests/pagination/tests.py
Dosyayı görüntüle @
b91a2a49
...
...
@@ -233,6 +233,12 @@ class PaginationTests(unittest.TestCase):
self
.
assertEqual
(
page2
.
previous_page_number
(),
1
)
self
.
assertIsNone
(
page2
.
next_page_number
())
def
test_page_range_iterator
(
self
):
"""
Paginator.page_range should be an iterator.
"""
self
.
assertIsInstance
(
Paginator
([
1
,
2
,
3
],
2
)
.
page_range
,
type
(
six
.
moves
.
range
(
0
)))
class
ModelPaginationTests
(
TestCase
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment