如何冻结未冻结的模型,以便继续使用南方?

时间:2021-11-24 19:44:32

Using a fork of someone else's code, I added a model field and did the usual auto migration:

使用别人代码的分支,我添加了一个模型字段并进行了通常的自动迁移:

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

I tried the obvious options using the hint to no avail, and got nowhere from the documentation.

我尝试使用提示的明显选项无济于事,并且从文档中无处可去。

1 个解决方案

#1


8  

OK, with some trial and error: I created a 'frozen migration' thus:

好的,经过一些试验和错误:我创建了一个'冻结迁移',因此:

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

Then I edited the resulting migration and deleted my added field so that:

然后我编辑了生成的迁移并删除了我添加的字段,以便:

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

with that done, the migration worked fine.

完成后,迁移工作正常。

#1


8  

OK, with some trial and error: I created a 'frozen migration' thus:

好的,经过一些试验和错误:我创建了一个'冻结迁移',因此:

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

Then I edited the resulting migration and deleted my added field so that:

然后我编辑了生成的迁移并删除了我添加的字段,以便:

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

with that done, the migration worked fine.

完成后,迁移工作正常。