使用别人的代码代码,我添加了一个模型字段并进行了常规的自动迁移:
~ $ django_admin.py migrate mezzanine_slides --auto
You cannot use automatic detection, since the previous migration does not have this whole app frozen.
Either make migrations using '--freeze mezzanine_slides' or set 'SOUTH_AUTO_FREEZE_APP = True' in your settings.py.
我尝试使用提示的明显选项无济于事,并且从文档中找不到。
答案 0 :(得分:8)
好的,经过一些试验和错误:我创建了一个“冷冻迁移”'因此:
~ $ django_admin.py schemamigration --freeze mezzanine_slides mezzanine_slides freeze --empty
Created 0002_freeze.py. You must now edit this migration and add the code for each direction.
然后我编辑了生成的迁移并删除了我添加的字段,以便:
! $ django_admin.py schemamigration mezzanine_slides --auto
+ Added field caption on mezzanine_slides.Slide
Created 0003_auto__add_field_slide_caption.py. You can now apply this migration with: ./manage.py migrate mezzanine_slides
完成后,迁移工作正常。