1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #36363 -- Added field names to admin duplicated fields error hint.

This commit is contained in:
Eric Blum
2025-05-01 16:31:06 -04:00
committed by Sarah Boyce
parent 358fd21c47
commit 384cdf0f7a
3 changed files with 54 additions and 5 deletions

View File

@@ -479,6 +479,7 @@ class SystemChecksTestCase(SimpleTestCase):
expected = [
checks.Error(
"The value of 'exclude' contains duplicate field(s).",
hint="Remove duplicates of 'name'.",
obj=ExcludedFields2,
id="admin.E015",
)
@@ -970,6 +971,7 @@ class SystemChecksTestCase(SimpleTestCase):
expected = [
checks.Error(
"The value of 'fields' contains duplicate field(s).",
hint="Remove duplicates of 'state'.",
obj=MyModelAdmin,
id="admin.E006",
)
@@ -986,12 +988,38 @@ class SystemChecksTestCase(SimpleTestCase):
expected = [
checks.Error(
"There are duplicate field(s) in 'fieldsets[0][1]'.",
hint="Remove duplicates of 'title', 'album'.",
obj=MyModelAdmin,
id="admin.E012",
)
]
self.assertEqual(errors, expected)
def test_check_multiple_duplicates_across_fieldsets(self):
class MyModelAdmin(admin.ModelAdmin):
fieldsets = [
("Header 1", {"fields": ["title", "album"]}),
("Header 2", {"fields": ["album", "name"]}),
("Header 3", {"fields": ["name", "other", "title"]}),
]
errors = MyModelAdmin(Song, AdminSite()).check()
expected = [
checks.Error(
"There are duplicate field(s) in 'fieldsets[1][1]'.",
hint="Remove duplicates of 'album'.",
obj=MyModelAdmin,
id="admin.E012",
),
checks.Error(
"There are duplicate field(s) in 'fieldsets[2][1]'.",
hint="Remove duplicates of 'title', 'name'.",
obj=MyModelAdmin,
id="admin.E012",
),
]
self.assertEqual(errors, expected)
def test_list_filter_works_on_through_field_even_when_apps_not_ready(self):
"""
Ensure list_filter can access reverse fields even when the app registry