Added model name to AutoField error message.
This commit is contained in:
parent
a20aae414e
commit
3d8fadad0f
|
@ -966,7 +966,7 @@ class AutoField(Field):
|
||||||
return int(value)
|
return int(value)
|
||||||
|
|
||||||
def contribute_to_class(self, cls, name, **kwargs):
|
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)
|
super().contribute_to_class(cls, name, **kwargs)
|
||||||
cls._meta.auto_field = self
|
cls._meta.auto_field = self
|
||||||
|
|
||||||
|
|
|
@ -130,4 +130,4 @@ try:
|
||||||
auto2 = models.AutoField(primary_key=True)
|
auto2 = models.AutoField(primary_key=True)
|
||||||
except AssertionError as exc:
|
except AssertionError as exc:
|
||||||
assertion_error = 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."
|
||||||
|
|
Loading…
Reference in New Issue