This prevents AppRegistryNotReady errors when unpickling Django models from an external script.
Thanks FunkyBob for the suggestion, prasoon2211 for the initial patch, and akaariai, loic, and charettes for helping in shaping the patch.