#20442: Stale ContentType objects cause a NoneType error in get_for_id
--------------------------------------+--------------------
Reporter: vdboor | Owner: vdboor
Type: Uncategorized | Status: new
Component: contrib.contenttypes | Version: 1.4
Severity: Normal | Keywords: dceu13
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+--------------------
When content types are stale an error occurs when using
`ContentType.objects.get_for_id()`:
{{{
Traceback (most recent call last):
...
File
"/Users/diederik/Sites/webapps/django/django/contrib/contenttypes/tests.py",
line 280, in <lambda>
test = ContentType.objects.get_for_id(ct.pk)
File
"/Users/diederik/Sites/webapps/django/django/contrib/contenttypes/models.py",
line 107, in get_for_id
self._add_to_cache(self.db, ct)
File
"/Users/diederik/Sites/webapps/django/django/contrib/contenttypes/models.py",
line 122, in _add_to_cache
key = (model._meta.app_label, model._meta.model_name)
AttributeError: 'NoneType' object has no attribute '_meta'
}}}
The object can still be fetched, but `ct.model_class()` returns `None`
which causes the `_add_to_cache` function to operate on a NoneType.
--
Ticket URL: <https://code.djangoproject.com/ticket/20442>
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].
For more options, visit https://groups.google.com/groups/opt_out.