问题
I've added a field to the main Django 'User' model, by inserting a User.add_to_class() to Askbot's models.init
the added code is the following:
#askbot-devel/askbot/models/__init__.py
User.add_to_class('show_active_status', models.BooleanField(default = False))
then I run South's schemamigration
$ ./manage.py schemamigration askbot --auto
Nothing seems to have changed.
As you can see it doesn't pick up the changes.
I've checked the database and nothing has changed at all.
Additionally, I've also checked that I'm working on the right init file because, besides tha fact that South is not picking up changes, when I run the server after saving the above changes it all breaks up, giving an error: 'current transaction is aborted, commands ignored until end of transaction block'
What am I doing wrong?
回答1:
Despite living in your askbot
app, this code changes a model in Django's auth
app. So according to south, the only thing that's changed is the auth
app. Given that this app is not managed by South, you run into a problem.
I'd not recommend using migrations for third-party apps for the simple fact that the migrations get lost in moving the code to different deployment environments.
Your best bet for an existing deployment is to manually add the column to the User
database table. New deployments will automatically pick up the new field and create the column during the syncdb
command.
来源:https://stackoverflow.com/questions/24180021/python-south-not-picking-up-changes-made-in-add-to-class-method