diff options
| author | Eric Blum <eric@enertiv.com> | 2025-05-01 16:31:06 -0400 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-05-08 11:38:13 +0100 |
| commit | 384cdf0f7a2c8d1793b120d82a1584776c064f44 (patch) | |
| tree | 17234cad549df8802cd487f3c4f161ed2c236984 /tests/admin_checks/tests.py | |
| parent | 358fd21c47cdf7bda520ce73c5cfd82bba57827b (diff) | |
Fixed #36363 -- Added field names to admin duplicated fields error hint.
Diffstat (limited to 'tests/admin_checks/tests.py')
| -rw-r--r-- | tests/admin_checks/tests.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/admin_checks/tests.py b/tests/admin_checks/tests.py index 6ca5d6d925..fc87260c9c 100644 --- a/tests/admin_checks/tests.py +++ b/tests/admin_checks/tests.py @@ -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 |
