summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorGavin Wahl <gwahl@fusionbox.com>2014-12-02 18:52:58 -0700
committerTim Graham <timograham@gmail.com>2014-12-03 08:22:29 -0500
commitdee4d23f7e703aec2d1244e4facbf7f4c88deed5 (patch)
treec448025ad1c702bdbab7c65a0bd7a434165c3a81 /django
parent9d1a69579b996eaa208f141b409141be63f597ec (diff)
Fixed #23950 -- Prevented calling deconstruct on classes in MigrationWriter.
Diffstat (limited to 'django')
-rw-r--r--django/db/migrations/writer.py28
1 files changed, 14 insertions, 14 deletions
diff --git a/django/db/migrations/writer.py b/django/db/migrations/writer.py
index 1e093778a5..dec0eae33d 100644
--- a/django/db/migrations/writer.py
+++ b/django/db/migrations/writer.py
@@ -330,6 +330,20 @@ class MigrationWriter(object):
elif isinstance(value, models.Field):
attr_name, path, args, kwargs = value.deconstruct()
return cls.serialize_deconstructed(path, args, kwargs)
+ # Classes
+ elif isinstance(value, type):
+ special_cases = [
+ (models.Model, "models.Model", []),
+ ]
+ for case, string, imports in special_cases:
+ if case is value:
+ return string, set(imports)
+ if hasattr(value, "__module__"):
+ module = value.__module__
+ if module == six.moves.builtins.__name__:
+ return value.__name__, set()
+ else:
+ return "%s.%s" % (module, value.__name__), {"import %s" % module}
# Anything that knows how to deconstruct itself.
elif hasattr(value, 'deconstruct'):
return cls.serialize_deconstructed(*value.deconstruct())
@@ -364,20 +378,6 @@ class MigrationWriter(object):
"https://docs.djangoproject.com/en/dev/topics/migrations/#serializing-values"
% (value.__name__, module_name))
return "%s.%s" % (module_name, value.__name__), {"import %s" % module_name}
- # Classes
- elif isinstance(value, type):
- special_cases = [
- (models.Model, "models.Model", []),
- ]
- for case, string, imports in special_cases:
- if case is value:
- return string, set(imports)
- if hasattr(value, "__module__"):
- module = value.__module__
- if module == six.moves.builtins.__name__:
- return value.__name__, set()
- else:
- return "%s.%s" % (module, value.__name__), {"import %s" % module}
# Other iterables
elif isinstance(value, collections.Iterable):
imports = set()