summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-12-17 17:25:28 +0100
committerClaude Paroz <claude@2xlibre.net>2014-12-17 18:41:12 +0100
commit47912d9f2b8f55044aef5b8ed9b006e8dd8ce976 (patch)
tree2eddbb35cfa0caa12c795f27cd20b2c42b545856 /django
parent6d8c14621e2878ea2051ee56326c66969a1d18d0 (diff)
[1.7.x] Fixed #24007 -- Ensure apps registry's ready before unpickling models
This prevents AppRegistryNotReady errors when unpickling Django models from an external script. Backport of 108b8bf85 from master.
Diffstat (limited to 'django')
-rw-r--r--django/db/models/base.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/django/db/models/base.py b/django/db/models/base.py
index e802dd955d..8037764dd8 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -1459,6 +1459,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.