I use South for schema and data migraton for my Django site. I'm happy about using it. One day I converted models.py
file to models/__init__py
and put some additional models at models/something.py
. When I ran python manage.py schemamigration app --auto
, I got the Nothing seems to have changed.
message despite of the new classes at something.py
. If I copied them to the __init__py
file, South had recognized the new models. I tried to import everything from something
in the top of __init__py
, but no change.
我为我的Django站点使用South进行模式和数据迁移。我很高兴使用它。有一天,我将models.py文件转换为models / __ init__py,并在models / something.py中添加了一些额外的模型。当我运行python manage.py schemamigration app --auto时,我得到了似乎没有任何改变。尽管在something.py中有新类,但仍会显示消息。如果我将它们复制到__init__py文件,South已经识别出新模型。我试图从__init__py顶部的东西导入所有东西,但没有变化。
17
It's Django design. Django is not picking your models at all, you need to set app_label
in your model's Meta class.
这是Django的设计。 Django根本不挑选你的模型,你需要在模型的Meta类中设置app_label。
See ticket on Automatically discover models within a package without using the app_label
Meta attribute.
请参阅自动发现程序包中的模型而不使用app_label Meta属性的故障单。
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2010/09/19/d363567276f5534a4d7781fc71c3556b.html。