Skip to content

Commit

Permalink
[3.2.x] Fixed #32863 -- Skipped system check for specifying type of a…
Browse files Browse the repository at this point in the history
…uto-created primary keys on models with invalid app_label.

Regression in b5e12d4.

Thanks Iuri de Silvio for the report.

Backport of 7a9745f from main
  • Loading branch information
hramezani authored and felixxm committed Jun 22, 2021
1 parent fb577d8 commit 8b2b627
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions django/db/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,7 @@ def _check_default_pk(cls):
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 [
Expand Down
3 changes: 3 additions & 0 deletions docs/releases/3.2.5.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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`).
7 changes: 7 additions & 0 deletions tests/check_framework/test_model_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,13 @@ class Child(Parent):

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:
Expand Down

0 comments on commit 8b2b627

Please sign in to comment.