Why does South not recognize changes in default field values in Python models? For example, take this existing model that is migrated with south:
class MyFamily(models.Model):
family_size = models.IntegerField(verbose_name="What is your family size?", default=2)
Now, I'd like to change the default value from two to four. However, when schemamigrating the module, South reports:
python manage.py schemamigration family --auto change_default_from_two_to_four_for_size
Running migrations for family:
- Nothing to migrate.
- Loading initial data for family.
I could manually update the initial migration, and use the SQL to directly update the field, but that's a pain. Is there a South command I haven't found that recognizes the change in the default?
Thanks!
South won't update the default value for existing columns, because it matters for him only when adding a new column to a non empty table. The django orm
will handle writing the new default value to new rows before hitting the database.
If you will work on the database from outside django orm
, you have to update it manually.
More explanations south/db.add_column
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With