diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index a2809de0dd..d607c27814 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -345,8 +345,7 @@ class AutoField(Field): return Field.get_manipulator_new_data(self, new_data, rel) def contribute_to_class(self, cls, name): - if cls._meta.has_auto_field: - raise AssertionError, "A model can't have more than one AutoField." + assert not cls._meta.has_auto_field, "A model can't have more than one AutoField." super(AutoField, self).contribute_to_class(cls, name) cls._meta.has_auto_field = True