【发布时间】:2014-08-08 08:52:01
【问题描述】:
我有一个自定义 django 管理命令,用于初始化应用程序迁移。麻烦的是,South 没有检测到命令中的新迁移。
for app in custom_apps:
call_command('schemamigration', app, initial=True)
call_command('migrate', app, fake=True)
这会创建初始迁移,但不会应用它们。
? You have no migrations for the 'profile' app. You might want some.
我尝试使用convert_to_south,但它只转换列表中的第一个应用程序,然后为其余应用程序提供此错误
This application has no models; this command is for applications that already have models syncdb'd.
Make some models, and then use ./manage.py schemamigration candidates --initial instead.
如果我手动运行这些命令,它们就会起作用。
不知道发生了什么。
【问题讨论】:
-
在运行管理命令之前是否运行了syncdb?另外,请参考这个 SO 问题:stackoverflow.com/questions/21309371/…
-
是的,我之前跑过
syncdb。那不是问题。问题是它不适用于 django shell 或管理命令。已经用两个不同的 django 项目进行了测试 -
您是否尝试过两次运行
call_command('schemamigration', app, initial=True)?有时我在运行schemamigration app --init时遇到同样的错误,然后我重新运行该命令并且它可以工作。 -
我也有同样的问题,你找到解决办法了吗??
标签: django django-south