summaryrefslogtreecommitdiff
path: root/django/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'django/contrib')
-rw-r--r--django/contrib/admin/checks.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py
index 35760a1177..045aaca346 100644
--- a/django/contrib/admin/checks.py
+++ b/django/contrib/admin/checks.py
@@ -239,6 +239,14 @@ class BaseModelAdminChecks:
except FieldDoesNotExist:
return refer_to_missing_field(field=field_name, option=label, obj=obj, id='admin.E002')
else:
+ # Using attname is not supported.
+ if field.name != field_name:
+ return refer_to_missing_field(
+ field=field_name,
+ option=label,
+ obj=obj,
+ id='admin.E002',
+ )
if not field.many_to_many and not isinstance(field, models.ForeignKey):
return must_be('a foreign key or a many-to-many field', option=label, obj=obj, id='admin.E003')
else: