#32863: Model.check() crashes on Django 3.2 with invalid app label
-------------------------------------+-------------------------------------
Reporter: Iuri de | Owner: nobody
Silvio |
Type: Bug | Status: new
Component: Database | Version: 3.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I found this issue in `django-cryptography` lib
(https://github.com/georgemarshall/django-cryptography). They have a test
with an invalid `app_label`, I'd expect model check to return `False`, but
it crashes when `DEFAULT_AUTO_FIELD` is not defined, because
`_meta.app_config=None` .
{{{
In [1]: from django.db import models
...: class Foo(models.Model):
...: class Meta:
...: app_label = 'bar'
...:
In [2]: Foo.check()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call
last)
<ipython-input-2-f17a07bccce5> in <module>
----> 1 Foo.check()
~django/db/models/base.py in check(cls, **kwargs)
1291 *cls._check_ordering(),
1292 *cls._check_constraints(databases),
-> 1293 *cls._check_default_pk(),
1294 ]
1295
~django/db/models/base.py in _check_default_pk(cls)
1307 ) and
1308 not settings.is_overridden('DEFAULT_AUTO_FIELD') and
-> 1309 not
cls._meta.app_config._is_default_auto_field_overridden
1310 ):
1311 return [
AttributeError: 'NoneType' object has no attribute
'_is_default_auto_field_overridden'
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32863>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/053.62269761b444e48b4750e0a09bc88ff0%40djangoproject.com.