diff --git a/django/contrib/admin/validation.py b/django/contrib/admin/validation.py
index 58a8490..9a0c948 100644
|
a
|
b
|
def validate(cls, model):
|
| 104 | 104 | field = opts.get_field_by_name(field_name)[0] |
| 105 | 105 | except models.FieldDoesNotExist: |
| 106 | 106 | raise ImproperlyConfigured("'%s.list_editable[%d]' refers to a " |
| 107 | | "field, '%s', not defined on %s." |
| 108 | | % (cls.__name__, idx, field_name, model.__name__)) |
| | 107 | "field, '%s', not defined on %s.%s." |
| | 108 | % (cls.__name__, idx, field_name, model._meta.app_label, model.__name__)) |
| 109 | 109 | if field_name not in cls.list_display: |
| 110 | 110 | raise ImproperlyConfigured("'%s.list_editable[%d]' refers to " |
| 111 | 111 | "'%s' which is not defined in 'list_display'." |
| … |
… |
def validate_inline(cls, parent, parent_model):
|
| 215 | 215 | if fk and fk.name in cls.exclude: |
| 216 | 216 | raise ImproperlyConfigured("%s cannot exclude the field " |
| 217 | 217 | "'%s' - this is the foreign key to the parent model " |
| 218 | | "%s." % (cls.__name__, fk.name, parent_model.__name__)) |
| | 218 | "%s.%s." % (cls.__name__, fk.name, parent_model._meta.app_label, parent_model.__name__)) |
| 219 | 219 | |
| 220 | 220 | if hasattr(cls, "readonly_fields"): |
| 221 | 221 | check_readonly_fields(cls, cls.model, cls.model._meta) |
| … |
… |
def get_field(cls, model, opts, label, field):
|
| 372 | 372 | try: |
| 373 | 373 | return opts.get_field(field) |
| 374 | 374 | except models.FieldDoesNotExist: |
| 375 | | raise ImproperlyConfigured("'%s.%s' refers to field '%s' that is missing from model '%s'." |
| 376 | | % (cls.__name__, label, field, model.__name__)) |
| | 375 | raise ImproperlyConfigured("'%s.%s' refers to field '%s' that is missing from model '%s.%s'." |
| | 376 | % (cls.__name__, label, field, model._meta.app_label, model.__name__)) |
| 377 | 377 | |
| 378 | 378 | def check_formfield(cls, model, opts, label, field): |
| 379 | 379 | if getattr(cls.form, 'base_fields', None): |
| … |
… |
def fetch_attr(cls, model, opts, label, field):
|
| 398 | 398 | try: |
| 399 | 399 | return getattr(model, field) |
| 400 | 400 | except AttributeError: |
| 401 | | raise ImproperlyConfigured("'%s.%s' refers to '%s' that is neither a field, method or property of model '%s'." |
| 402 | | % (cls.__name__, label, field, model.__name__)) |
| | 401 | raise ImproperlyConfigured("'%s.%s' refers to '%s' that is neither a field, method or property of model '%s.%s'." |
| | 402 | % (cls.__name__, label, field, model._meta.app_label, model.__name__)) |
| 403 | 403 | |
| 404 | 404 | def check_readonly_fields(cls, model, opts): |
| 405 | 405 | check_isseq(cls, "readonly_fields", cls.readonly_fields) |
diff --git a/tests/regressiontests/admin_validation/tests.py b/tests/regressiontests/admin_validation/tests.py
index 2cf3c60..9e50a8b 100644
|
a
|
b
|
class ValidationTestCase(TestCase):
|
| 92 | 92 | inlines = [SongInline] |
| 93 | 93 | |
| 94 | 94 | self.assertRaisesMessage(ImproperlyConfigured, |
| 95 | | "SongInline cannot exclude the field 'album' - this is the foreign key to the parent model Album.", |
| | 95 | "SongInline cannot exclude the field 'album' - this is the foreign key to the parent model admin_validation.Album.", |
| 96 | 96 | validate, |
| 97 | 97 | AlbumAdmin, Album) |
| 98 | 98 | |
| | 99 | def test_app_label_in_admin_validation(self): |
| | 100 | """ |
| | 101 | Regression test for #15669 - Include app label in admin validation messages |
| | 102 | """ |
| | 103 | class RawIdNonexistingAdmin(admin.ModelAdmin): |
| | 104 | raw_id_fields = ('nonexisting',) |
| | 105 | |
| | 106 | self.assertRaisesMessage(ImproperlyConfigured, |
| | 107 | "'RawIdNonexistingAdmin.raw_id_fields' refers to field 'nonexisting' that is missing from model 'admin_validation.Album'.", |
| | 108 | validate, |
| | 109 | RawIdNonexistingAdmin, Album) |
| | 110 | |
| 99 | 111 | def test_fk_exclusion(self): |
| 100 | 112 | """ |
| 101 | 113 | Regression test for #11709 - when testing for fk excluding (when exclude is |