Fixed #32863 -- Skipped system check for specifying type of auto-created primary keys on models with invalid app_label.

Regression in b5e12d490a.

Thanks Iuri de Silvio for the report.
This commit is contained in:
Hasan Ramezani 2021-06-21 16:57:06 +02:00 committed by Mariusz Felisiak
parent 1697098795
commit 7a9745fed4
3 changed files with 11 additions and 0 deletions

View File

@ -1310,6 +1310,7 @@ class Model(metaclass=ModelBase):
cls._meta.pk.remote_field.parent_link
) and
not settings.is_overridden('DEFAULT_AUTO_FIELD') and
cls._meta.app_config and
not cls._meta.app_config._is_default_auto_field_overridden
):
return [

View File

@ -20,3 +20,6 @@ Bugfixes
* Fixed a regression in Django 3.2 that caused a migration crash on MySQL
8.0.13+ when adding nullable ``BinaryField``, ``JSONField``, or ``TextField``
with a default value (:ticket:`32832`).
* Fixed a bug in Django 3.2 where a system check would crash on a model with an
invalid ``app_label`` (:ticket:`32863`).

View File

@ -403,6 +403,13 @@ class ModelDefaultAutoFieldTests(SimpleTestCase):
self.assertEqual(checks.run_checks(app_configs=self.apps.get_app_configs()), [])
def test_skipped_on_model_with_invalid_app_label(self):
class Model(models.Model):
class Meta:
app_label = 'invalid_app_label'
self.assertEqual(Model.check(), [])
def test_skipped_on_abstract_model(self):
class Abstract(models.Model):
class Meta: