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
c0f12a09
Kaydet (Commit)
c0f12a09
authored
Nis 21, 2017
tarafından
Simon Charette
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28109 -- Corrected the stack level of unordered queryset pagination warnings.
Refs #26290. Thanks Tim for the review.
üst
c52ae33a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
5 deletions
+18
-5
paginator.py
django/core/paginator.py
+2
-1
1.11.1.txt
docs/releases/1.11.1.txt
+3
-0
tests.py
tests/pagination/tests.py
+13
-4
No files found.
django/core/paginator.py
Dosyayı görüntüle @
c0f12a09
...
...
@@ -100,7 +100,8 @@ class Paginator:
warnings
.
warn
(
'Pagination may yield inconsistent results with an unordered '
'object_list: {!r}'
.
format
(
self
.
object_list
),
UnorderedObjectListWarning
UnorderedObjectListWarning
,
stacklevel
=
3
)
...
...
docs/releases/1.11.1.txt
Dosyayı görüntüle @
c0f12a09
...
...
@@ -49,3 +49,6 @@ Bugfixes
* Fixed a regression where ``CheckboxSelectMultiple``, ``NullBooleanSelect``,
``RadioSelect``, ``SelectMultiple``, and ``Select`` localized option values
(:ticket:`28075`).
* Corrected the stack level of unordered queryset pagination warnings
(:ticket:`28109`).
tests/pagination/tests.py
Dosyayı görüntüle @
c0f12a09
import
unittest
import
warnings
from
datetime
import
datetime
from
django.core.paginator
import
(
...
...
@@ -318,12 +319,20 @@ class ModelPaginationTests(TestCase):
self
.
assertIsInstance
(
p
.
object_list
,
list
)
def
test_paginating_unordered_queryset_raises_warning
(
self
):
msg
=
(
with
warnings
.
catch_warnings
(
record
=
True
)
as
warns
:
# Prevent the RuntimeWarning subclass from appearing as an
# exception due to the warnings.simplefilter() in runtests.py.
warnings
.
filterwarnings
(
'always'
,
category
=
UnorderedObjectListWarning
)
Paginator
(
Article
.
objects
.
all
(),
5
)
self
.
assertEqual
(
len
(
warns
),
1
)
warning
=
warns
[
0
]
self
.
assertEqual
(
str
(
warning
.
message
),
(
"Pagination may yield inconsistent results with an unordered "
"object_list: <QuerySet [<Article: Article 1>, "
"<Article: Article 2>, <Article: Article 3>, <Article: Article 4>, "
"<Article: Article 5>, <Article: Article 6>, <Article: Article 7>, "
"<Article: Article 8>, <Article: Article 9>]>"
)
with
self
.
assertRaisesMessage
(
UnorderedObjectListWarning
,
msg
):
Paginator
(
Article
.
objects
.
all
(),
5
)
))
# The warning points at the Paginator caller (i.e. the stacklevel
# is appropriate).
self
.
assertEqual
(
warning
.
filename
,
__file__
)
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