1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #25807 -- Instructed the migration writer about lazy objects.

Thanks to Trac alias mrgaolei for the report, Baptiste for the confirmation
and Tim for the review.
This commit is contained in:
Simon Charette
2015-11-25 12:31:23 -05:00
parent 831514867c
commit cc2ca9c550
4 changed files with 16 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ from django.db.migrations.utils import COMPILED_REGEX_TYPE, RegexObject
from django.utils import datetime_safe, six
from django.utils._os import upath
from django.utils.encoding import force_text
from django.utils.functional import Promise
from django.utils.functional import LazyObject, Promise
from django.utils.inspect import get_func_args
from django.utils.module_loading import module_dir
from django.utils.timezone import now, utc
@@ -350,6 +350,10 @@ class MigrationWriter(object):
# process.
if isinstance(value, Promise):
value = force_text(value)
elif isinstance(value, LazyObject):
# The unwrapped value is returned as the first item of the
# arguments tuple.
value = value.__reduce__()[1][0]
# Sequences
if isinstance(value, (frozenset, list, set, tuple)):