Loading django/db/migrations/operations/special.py +2 −16 Original line number Diff line number Diff line Loading @@ -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) 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) def describe(self): return "Raw Python operation" Loading
django/db/migrations/operations/special.py +2 −16 Original line number Diff line number Diff line Loading @@ -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) 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) def describe(self): return "Raw Python operation"