Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does Django South require a default value when removing a field?

When I am removing a NOT NULL field using Django South, I get the following message:

? 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: 

Why does South need this, given it's going to remove the field anyhow?

like image 432
Ghopper21 Avatar asked Aug 07 '12 15:08

Ghopper21


1 Answers

Django South allows you to move forwards or backwards through migrations. So, if you ever decided to undo a migration, South would re-create the fields that were deleted. That is why South is asking if you want to specify a default value or "disable the backwards migration by raising an exception."

like image 199
Garrett Hyde Avatar answered Nov 17 '22 07:11

Garrett Hyde