Fixed #25267 -- Corrected message for admin.E122 system check.
This commit is contained in:
parent
0cc059cd10
commit
ece78684d9
|
@ -774,8 +774,15 @@ class ModelAdminChecks(BaseModelAdminChecks):
|
||||||
model=model, obj=cls, id='admin.E121')
|
model=model, obj=cls, id='admin.E121')
|
||||||
else:
|
else:
|
||||||
if field_name not in cls.list_display:
|
if field_name not in cls.list_display:
|
||||||
return refer_to_missing_field(field=field_name, option=label,
|
return [
|
||||||
model=model, obj=cls, id='admin.E122')
|
checks.Error(
|
||||||
|
"The value of '%s' refers to '%s', which is not "
|
||||||
|
"contained in 'list_display'." % (label, field_name),
|
||||||
|
hint=None,
|
||||||
|
obj=cls,
|
||||||
|
id='admin.E122',
|
||||||
|
)
|
||||||
|
]
|
||||||
elif cls.list_display_links and 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(
|
||||||
|
|
|
@ -69,6 +69,22 @@ class SystemChecksTestCase(SimpleTestCase):
|
||||||
custom_site.unregister(Song)
|
custom_site.unregister(Song)
|
||||||
admin.sites.system_check_errors = []
|
admin.sites.system_check_errors = []
|
||||||
|
|
||||||
|
def test_field_name_not_in_list_display(self):
|
||||||
|
class SongAdmin(admin.ModelAdmin):
|
||||||
|
list_editable = ["original_release"]
|
||||||
|
|
||||||
|
errors = SongAdmin.check(model=Song)
|
||||||
|
expected = [
|
||||||
|
checks.Error(
|
||||||
|
"The value of 'list_editable[0]' refers to 'original_release', "
|
||||||
|
"which is not contained in 'list_display'.",
|
||||||
|
hint=None,
|
||||||
|
obj=SongAdmin,
|
||||||
|
id='admin.E122',
|
||||||
|
)
|
||||||
|
]
|
||||||
|
self.assertEqual(errors, expected)
|
||||||
|
|
||||||
def test_readonly_and_editable(self):
|
def test_readonly_and_editable(self):
|
||||||
class SongAdmin(admin.ModelAdmin):
|
class SongAdmin(admin.ModelAdmin):
|
||||||
readonly_fields = ["original_release"]
|
readonly_fields = ["original_release"]
|
||||||
|
|
Loading…
Reference in New Issue