summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2014-02-12 17:21:25 +0000
committerAndrew Godwin <andrew@aeracode.org>2014-02-12 17:21:25 +0000
commit80bbe2265d1afd43f8519427ad8ce0b147aceb43 (patch)
treef2a2ab7ebe11cf2e2551d5b6c368a9a4d063ed97
parentb333de0f5dc6e66bd77cce9ffe0eef06a9e31f02 (diff)
Remove redunant code from RunPython operation
-rw-r--r--django/db/migrations/operations/special.py18
1 files changed, 2 insertions, 16 deletions
diff --git a/django/db/migrations/operations/special.py b/django/db/migrations/operations/special.py
index 91afa14326..714a6d59f9 100644
--- a/django/db/migrations/operations/special.py
+++ b/django/db/migrations/operations/special.py
@@ -128,26 +128,12 @@ class RunPython(Operation):
# object, representing the versioned models as an app registry.
# We could try to override the global cache, but then people will still
# use direct imports, so we go with a documentation approach instead.
- if callable(self.code):
- self.code(models=from_state.render(), schema_editor=schema_editor)
- else:
- context = {
- "models": from_state.render(),
- "schema_editor": schema_editor,
- }
- eval(self.code, context)
+ self.code(models=from_state.render(), schema_editor=schema_editor)
def database_backwards(self, app_label, schema_editor, from_state, to_state):
if self.reverse_code is None:
raise NotImplementedError("You cannot reverse this operation")
- elif callable(self.reverse_code):
- self.reverse_code(models=from_state.render(), schema_editor=schema_editor)
- else:
- context = {
- "models": from_state.render(),
- "schema_editor": schema_editor,
- }
- eval(self.reverse_code, context)
+ self.reverse_code(models=from_state.render(), schema_editor=schema_editor)
def describe(self):
return "Raw Python operation"