mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[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.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user