diff --git a/django/contrib/admin/validation.py b/django/contrib/admin/validation.py index 48e35c68b3..9b9cefab98 100644 --- a/django/contrib/admin/validation.py +++ b/django/contrib/admin/validation.py @@ -39,7 +39,7 @@ def validate(cls, model): if not hasattr(cls, field): if not hasattr(model, field): try: - return opts.get_field(field) + opts.get_field(field) except models.FieldDoesNotExist: raise ImproperlyConfigured("%s.list_display[%d], %r is " "not a callable or an attribute of %r or found in the model %r." diff --git a/tests/regressiontests/modeladmin/models.py b/tests/regressiontests/modeladmin/models.py index 0fdd9afdf1..488947ad3e 100644 --- a/tests/regressiontests/modeladmin/models.py +++ b/tests/regressiontests/modeladmin/models.py @@ -559,7 +559,8 @@ ImproperlyConfigured: `ValidationTestModelAdmin.list_display` must be a list or >>> validate(ValidationTestModelAdmin, ValidationTestModel) Traceback (most recent call last): ... -ImproperlyConfigured: `ValidationTestModelAdmin.list_display[0]` refers to `non_existent_field` that is neither a field, method or property of model `ValidationTestModel`. +ImproperlyConfigured: ValidationTestModelAdmin.list_display[0], 'non_existent_field' is not a callable or an attribute of 'ValidationTestModelAdmin' or found in the model 'ValidationTestModel'. + >>> class ValidationTestModelAdmin(ModelAdmin): ... list_display = ('users',)