Skip to content

Instantly share code, notes, and snippets.

@claudep
Created December 17, 2014 11:19
Show Gist options
  • Save claudep/cea224ff21a992fd848a to your computer and use it in GitHub Desktop.
Save claudep/cea224ff21a992fd848a to your computer and use it in GitHub Desktop.
diff --git a/django/db/models/base.py b/django/db/models/base.py
index c2f711e..dedfbee 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -1659,6 +1659,8 @@ def model_unpickle(model_id, attrs, factory):
Used to unpickle Model subclasses with deferred fields.
"""
if isinstance(model_id, tuple):
+ if not apps.ready:
+ apps.populate(settings.INSTALLED_APPS)
model = apps.get_model(*model_id)
else:
# Backwards compat - the model was cached directly in earlier versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment