首页 文章

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

提问于
浏览
19

当我使用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 回答

  • 33

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

相关问题