2014-03-26 26 views
7

使用別人的代碼叉子,我增加了一個模式場,做一般的自動遷移:如何凍結解凍模型,以便繼續使用南?

~ $ 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. 

我使用的提示無果嘗試了明顯的選項,並從文檔毫無進展。

回答

8

OK,有一些試驗和錯誤:我創建了一個「凍結流動」這樣的:

~ $ 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 

這樣做,遷移工作正常。