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
8f76673f
Kaydet (Commit)
8f76673f
authored
Eki 23, 2016
tarafından
nmhung89
Kaydeden (comit)
Tim Graham
Ara 06, 2016
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #18729 -- Made admin changelist not use distinct() if a list_filter doesn't require it.
üst
d0112cf9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
2 deletions
+23
-2
main.py
django/contrib/admin/views/main.py
+7
-2
tests.py
tests/admin_changelist/tests.py
+16
-0
No files found.
django/contrib/admin/views/main.py
Dosyayı görüntüle @
8f76673f
...
...
@@ -125,12 +125,17 @@ class ChangeList(object):
if
not
isinstance
(
field
,
models
.
Field
):
field_path
=
field
field
=
get_fields_from_path
(
self
.
model
,
field_path
)[
-
1
]
lookup_params_count
=
len
(
lookup_params
)
spec
=
field_list_filter_class
(
field
,
request
,
lookup_params
,
self
.
model
,
self
.
model_admin
,
field_path
=
field_path
)
# Check if we need to use distinct()
use_distinct
=
use_distinct
or
lookup_needs_distinct
(
self
.
lookup_opts
,
field_path
)
# field_list_filter_class removes any lookup_params it
# processes. If that happened, check if distinct() is
# needed to remove duplicate results.
if
lookup_params_count
>
len
(
lookup_params
):
use_distinct
=
use_distinct
or
lookup_needs_distinct
(
self
.
lookup_opts
,
field_path
)
if
spec
and
spec
.
has_output
():
filter_specs
.
append
(
spec
)
...
...
tests/admin_changelist/tests.py
Dosyayı görüntüle @
8f76673f
...
...
@@ -445,6 +445,22 @@ class ChangeListTests(TestCase):
# There's only one Concert instance
self
.
assertEqual
(
cl
.
queryset
.
count
(),
1
)
def
test_no_distinct_for_m2m_in_list_filter_without_params
(
self
):
"""
If a ManyToManyField is in list_filter but isn't in any lookup params,
the changelist's query shouldn't have distinct.
"""
m
=
BandAdmin
(
Band
,
custom_site
)
for
lookup_params
in
({},
{
'name'
:
'test'
}):
request
=
self
.
factory
.
get
(
'/band/'
,
lookup_params
)
cl
=
ChangeList
(
request
,
Band
,
*
get_changelist_args
(
m
))
self
.
assertFalse
(
cl
.
queryset
.
query
.
distinct
)
# A ManyToManyField in params does have distinct applied.
request
=
self
.
factory
.
get
(
'/band/'
,
{
'genres'
:
'0'
})
cl
=
ChangeList
(
request
,
Band
,
*
get_changelist_args
(
m
))
self
.
assertTrue
(
cl
.
queryset
.
query
.
distinct
)
def
test_pagination
(
self
):
"""
Regression tests for #12893: Pagination in admins changelist doesn't
...
...
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