Python South not picking up changes made in add_to_class() method

一个人想着一个人 提交于 2019-12-25 02:53:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!