django/django — pull request #1130 by vdboor (2013-05-18 15:42:54+00:00)
Title: Fix NoneType error when fetching a stale ContentType with get_for_id

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