diff --git a/django/db/models/base.py b/django/db/models/base.py index cd5268bed10..0f8af9f9204 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -1302,6 +1302,7 @@ class Model(metaclass=ModelBase): @classmethod def _check_default_pk(cls): if ( + not cls._meta.abstract and cls._meta.pk.auto_created and # Inherited PKs are checked in parents models. not ( diff --git a/docs/releases/3.2.4.txt b/docs/releases/3.2.4.txt index 51a48981636..068798e6ede 100644 --- a/docs/releases/3.2.4.txt +++ b/docs/releases/3.2.4.txt @@ -12,3 +12,6 @@ Bugfixes * Fixed a bug in Django 3.2 where a final catch-all view in the admin didn't respect the server-provided value of ``SCRIPT_NAME`` when redirecting unauthenticated users to the login page (:ticket:`32754`). + +* Fixed a bug in Django 3.2 where a system check would crash on an abstract + model (:ticket:`32733`). diff --git a/tests/check_framework/test_model_checks.py b/tests/check_framework/test_model_checks.py index cf0aca404f5..5c62ace7e44 100644 --- a/tests/check_framework/test_model_checks.py +++ b/tests/check_framework/test_model_checks.py @@ -403,6 +403,14 @@ class ModelDefaultAutoFieldTests(SimpleTestCase): self.assertEqual(checks.run_checks(app_configs=self.apps.get_app_configs()), []) + def test_skipped_on_abstract_model(self): + class Abstract(models.Model): + class Meta: + abstract = True + + # Call .check() because abstract models are not registered. + self.assertEqual(Abstract.check(), []) + def test_explicit_inherited_parent_link(self): class Parent(models.Model): id = models.AutoField(primary_key=True)