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
d232a5f9
Kaydet (Commit)
d232a5f9
authored
Haz 10, 2014
tarafından
Greg Chapple
Kaydeden (comit)
Tim Graham
Haz 10, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[1.7.x] Fixed #22792 -- Updated checks for list_display_links in model admin
Backport of
d8f19bb3
from master
üst
e108da65
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
2 deletions
+29
-2
checks.py
django/contrib/admin/checks.py
+5
-2
tests.py
tests/modeladmin/tests.py
+24
-0
No files found.
django/contrib/admin/checks.py
Dosyayı görüntüle @
d232a5f9
...
@@ -779,7 +779,7 @@ class ModelAdminChecks(BaseModelAdminChecks):
...
@@ -779,7 +779,7 @@ class ModelAdminChecks(BaseModelAdminChecks):
obj
=
cls
,
obj
=
cls
,
id
=
'admin.E122'
,
id
=
'admin.E122'
,
),
),
elif
field_name
in
cls
.
list_display_links
:
elif
cls
.
list_display_links
and
field_name
in
cls
.
list_display_links
:
return
[
return
[
checks
.
Error
(
checks
.
Error
(
"The value of '
%
s' cannot be in both 'list_editable' and 'list_display_links'."
%
field_name
,
"The value of '
%
s' cannot be in both 'list_editable' and 'list_display_links'."
%
field_name
,
...
@@ -788,7 +788,10 @@ class ModelAdminChecks(BaseModelAdminChecks):
...
@@ -788,7 +788,10 @@ class ModelAdminChecks(BaseModelAdminChecks):
id
=
'admin.E123'
,
id
=
'admin.E123'
,
)
)
]
]
elif
not
cls
.
list_display_links
and
cls
.
list_display
[
0
]
in
cls
.
list_editable
:
# Check that list_display_links is set, and that the first values of list_editable and list_display are
# not the same. See ticket #22792 for the use case relating to this.
elif
(
cls
.
list_display
[
0
]
in
cls
.
list_editable
and
cls
.
list_display
[
0
]
!=
cls
.
list_editable
[
0
]
and
cls
.
list_display_links
is
not
None
):
return
[
return
[
checks
.
Error
(
checks
.
Error
(
"The value of '
%
s' refers to the first field in 'list_display' ('
%
s'), "
"The value of '
%
s' refers to the first field in 'list_display' ('
%
s'), "
...
...
tests/modeladmin/tests.py
Dosyayı görüntüle @
d232a5f9
...
@@ -1518,3 +1518,27 @@ class CustomModelAdminTests(CheckTestCase):
...
@@ -1518,3 +1518,27 @@ class CustomModelAdminTests(CheckTestCase):
validator_class
=
CustomValidator
validator_class
=
CustomValidator
self
.
assertIsInvalid
(
CustomModelAdmin
,
ValidationTestModel
,
'error!'
)
self
.
assertIsInvalid
(
CustomModelAdmin
,
ValidationTestModel
,
'error!'
)
class
ListDisplayEditableTests
(
CheckTestCase
):
def
test_list_display_links_is_none
(
self
):
"""
list_display and list_editable can contain the same values
when list_display_links is None
"""
class
ProductAdmin
(
ModelAdmin
):
list_display
=
[
'name'
,
'slug'
,
'pub_date'
]
list_editable
=
list_display
list_display_links
=
None
self
.
assertIsValid
(
ProductAdmin
,
ValidationTestModel
)
def
test_list_display_same_as_list_editable
(
self
):
"""
The first item in list_display can be the same as the first
in list_editable
"""
class
ProductAdmin
(
ModelAdmin
):
list_display
=
[
'name'
,
'slug'
,
'pub_date'
]
list_editable
=
[
'name'
,
'slug'
]
list_display_links
=
[
'pub_date'
]
self
.
assertIsValid
(
ProductAdmin
,
ValidationTestModel
)
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