summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlmad <bugs@almad.net>2018-03-03 19:22:00 +0100
committerTim Graham <timograham@gmail.com>2018-03-03 13:22:00 -0500
commit3d8fadad0f7a3a32f28db034650182117ae071f7 (patch)
treebc27577b4ee8dec7682e4fd79c98e7e3f0cfef99
parenta20aae414e762e4d9043e76b0bf8eccd334c8ebc (diff)
Added model name to AutoField error message.
-rw-r--r--django/db/models/fields/__init__.py2
-rw-r--r--tests/validation/models.py2
2 files changed, 2 insertions, 2 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index e9903a73b6..ea31096374 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -966,7 +966,7 @@ class AutoField(Field):
return int(value)
def contribute_to_class(self, cls, name, **kwargs):
- assert not cls._meta.auto_field, "A model can't have more than one AutoField."
+ assert not cls._meta.auto_field, "Model %s can't have more than one AutoField." % cls._meta.label
super().contribute_to_class(cls, name, **kwargs)
cls._meta.auto_field = self
diff --git a/tests/validation/models.py b/tests/validation/models.py
index f954cc3a4f..953370bc37 100644
--- a/tests/validation/models.py
+++ b/tests/validation/models.py
@@ -130,4 +130,4 @@ try:
auto2 = models.AutoField(primary_key=True)
except AssertionError as exc:
assertion_error = exc
-assert str(assertion_error) == "A model can't have more than one AutoField."
+assert str(assertion_error) == "Model validation.MultipleAutoFields can't have more than one AutoField."