[英]Django-South DataMigration - App available in forwards() but not backwards()?
I am writing a django south migration that depends on the model in another app, so I have included --freeze OTHERAPPNAME
when I ran python manage.py datamigration …
我正在编写一个django南迁移,它取决于另一个应用程序中的模型,所以我在运行python manage.py datamigration …
--freeze OTHERAPPNAME
时包含了--freeze OTHERAPPNAME
python manage.py datamigration …
However in the forwards()
function I can access the other model fine (with orm['otherappname.MyModelName']
), however in the backwards()
step (which also depends on the model in otherappname), if I try to access orm['otherappname.MyModelName']
, I get an error 但是在forwards()
函数中我可以访问其他模型(使用orm['otherappname.MyModelName']
),但是在backwards()
步骤中(这也取决于其他名称中的模型),如果我尝试访问orm['otherappname.MyModelName']
,我收到一个错误
*** KeyError: "The model 'mymodelname' from the app 'otherappname' is not available in this migration."
I can see the frozen model details in the bottom of the file. 我可以在文件底部看到冻结的模型细节。 Why can't I access it? 为什么我不能访问它?
NB: This model is created in another migration inside otherappname of which this datamigration depends on. 注意:此模型是在此数据迁移所依赖的其他迁移内创建的。
The backwards migration actually uses the frozen ORM of the previous migration. 向后迁移实际上使用先前迁移的冻结ORM。 It's logical when you think about it, but it's admittedly not very intuitive. 你考虑它是合乎逻辑的,但它确实不是很直观。
Moral: freeze the models you'll need in your datamigration in the schemamigration that proceeds it. 道德:冻结您在进行数据迁移的模式迁移中需要的模型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.