1
0
mirror of https://github.com/django/django.git synced 2025-10-29 00:26:07 +00:00

Autodetect fields, have migrate actually work

This commit is contained in:
Andrew Godwin
2013-06-19 16:41:04 +01:00
parent f25a385a5e
commit 41214eaf18
4 changed files with 33 additions and 5 deletions

View File

@@ -6,13 +6,13 @@ class AddField(Operation):
Adds a field to a model.
"""
def __init__(self, model_name, name, instance):
def __init__(self, model_name, name, field):
self.model_name = model_name
self.name = name
self.instance = instance
self.field = field
def state_forwards(self, app_label, state):
state.models[app_label, self.model_name.lower()].fields.append((self.name, self.instance))
state.models[app_label, self.model_name.lower()].fields.append((self.name, self.field))
def database_forwards(self, app_label, schema_editor, from_state, to_state):
from_model = from_state.render().get_model(app_label, self.model_name)