Python南没有收到add_to_class()方法所做的更改 [英] Python South not picking up changes made in add_to_class() method

查看:497
本文介绍了Python南没有收到add_to_class()方法所做的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经添加了一个字段到主Django'User'模型,通过插入一个User.add_to_class()到Askbot的模型。 init

I've added a field to the main Django 'User' model, by inserting a User.add_to_class() to Askbot's models.init

添加的代码如下:

#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.

此外,我还检查了我在正确的工作 init 文件,因为除了南方没有收到更改之外,当我在保存上述更改后运行服务器时都会中断,给出错误:'当前事务中止,忽略命令,直到交易块结束'

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'

我做错了什么?

推荐答案

尽管生活在您的 askbot 应用程序中,此代码会更改Django的 auth 应用程序中的模型。所以根据南方,唯一改变的是 auth 应用程序。鉴于此应用程序不是由南方管理,您遇到问题。

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.

现有部署的最佳选择是手动将列添加到 User 数据库表中。新的部署将自动拾取新字段,并在 syncdb 命令期间创建列。

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.

这篇关于Python南没有收到add_to_class()方法所做的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆