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
31f6421b
Kaydet (Commit)
31f6421b
authored
Mar 18, 2013
tarafından
Andrew Jesaitis
Kaydeden (comit)
Claude Paroz
May 25, 2013
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #19938 -- Consumed iterator only once in paginator's Page
Thanks Joshua Fialkoff for the report.
üst
2ee447fb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletion
+6
-1
paginator.py
django/core/paginator.py
+3
-1
tests.py
tests/pagination/tests.py
+3
-0
No files found.
django/core/paginator.py
Dosyayı görüntüle @
31f6421b
...
...
@@ -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
...
...
tests/pagination/tests.py
Dosyayı görüntüle @
31f6421b
...
...
@@ -297,6 +297,7 @@ class ModelPaginationTests(TestCase):
self
.
assertIsNone
(
p
.
object_list
.
_result_cache
)
self
.
assertRaises
(
TypeError
,
lambda
:
p
[
'has_previous'
])
self
.
assertIsNone
(
p
.
object_list
.
_result_cache
)
self
.
assertNotIsInstance
(
p
.
object_list
,
list
)
# Make sure slicing the Page object with numbers and slice objects work.
self
.
assertEqual
(
p
[
0
],
Article
.
objects
.
get
(
headline
=
'Article 1'
))
...
...
@@ -305,3 +306,5 @@ class ModelPaginationTests(TestCase):
"<Article: Article 2>"
,
]
)
# After __getitem__ is called, object_list is a list
self
.
assertIsInstance
(
p
.
object_list
,
list
)
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