Fix NoneType error when fetching a stale ContentType with get_for_id #1130

Merged
merged 1 commit into from May 19, 2013

Projects

None yet

2 participants

Contributor
vdboor commented May 18, 2013

When a stale ContentType is fetched with get_for_id(), a NoneType error was raised.

The _add_to_cache() function didn't detect that model_class() returns None (which it does by design). However, the app_label + model fields can be used instead to as local cache key. Third party apps can detect stale models by checking whether model_class() returns None; as they'd previously had to do as well.

Ticket: https://code.djangoproject.com/ticket/20442

@vdboor vdboor Fix NoneType error when fetching a stale ContentType with get_for_id
When a stale ContentType is fetched, the _add_to_cache() function
didn't detect that `model_class()` returns `None` (which it does by
design). However, the `app_label` + `model` fields can be used instead
to as local cache key. Third party apps can detect stale models by
checking whether `model_class()` returns `None`.

Ticket: https://code.djangoproject.com/ticket/20442
86e761f
@andrewgodwin andrewgodwin merged commit 9b22bad into django:master May 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment