为什么Django South在删除字段时需要默认值?

时间:2012-08-07 15:05:54

标签: django django-south

当我使用Django South删除NOT NULL字段时,我收到以下消息:

? The field 'VisitOrder.end_date' does not have a default specified, yet is NOT NULL.
? Since you are removing this field, you MUST specify a default
? value to use for existing rows. Would you like to:
?  1. Quit now, and add a default to the field in models.py
?  2. Specify a one-off value to use for existing columns now
?  3. Disable the backwards migration by raising an exception.
? Please select a choice: 

为什么南方需要这个,因为它无论如何都会移除这个领域?

1 个答案:

答案 0 :(得分:33)

Django South允许您通过迁移向前或向后移动。因此,如果您决定撤消迁移,South将重新创建已删除的字段。这就是为什么South要求您指定默认值或“通过引发异常来禁用 向后 迁移。”