#26686: django.core.checks.model_checks _check_lazy_references raises TypeError
with NoneType model_key
--------------------------------------+------------------------------------
Reporter: bretth | Owner: nobody
Type: Bug | Status: new
Component: Core (System checks) | Version: 1.10
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Comment (by AlexHill):
If you're only using abstract models, you shouldn't need to add to
`INSTALLED_APPS`.
[https://github.com/django/django/blob/62e4f8ec435a4b600c8efb071201070a2443477e/django/db/models/base.py#L109
This is explicitly allowed in models/base.py]
I've found a bug in `ModelSignal`. It contains a conditional branch for
senders of type `Model`, but it should be checking for `BaseModel`, since
model signals are used with classes, not instances. Fixing that fixes this
problem.
The long version of what's happening is:
* _lazy_model_operation works by waiting for models to be registered
* abstract models are never registered with the app registry, so their
operations will remain forever pending
* [https://github.com/carljm/django-model-
utils/blob/c94b65d05f4acd0437a22ef498a80470922a438a/model_utils/models.py#L54
StatusModel is abstract, and has a MonitorField]
* [https://github.com/carljm/django-model-
utils/blob/c94b65d05f4acd0437a22ef498a80470922a438a/model_utils/fields.py#L106
MonitorField connects to the `post_init` signal in its
`contribute_to_class()` method]
* signals use _lazy_model_operation as of 1.10
* the bug means _lazy_model_operation is used by the `post_init` signal
even when a model class is provided, not a string.
Incidentally, we currently happily register model signals with abstract
senders even though they'll never be sent. Since perfectly reasonable code
like the linked code in django-model-utils does this, I don't think a
warning is appropriate. I think we should just ignore them explicitly in
ModelSignal and document that behaviour. Thoughts?
--
Ticket URL: <https://code.djangoproject.com/ticket/26686#comment:4>
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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.bc17db2d39a30f5f8bca269aeb580571%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.