13

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!

MontyThreeCard
  • 821
  • 9
  • 14

1 Answers1

11

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

manji
  • 47,442
  • 5
  • 96
  • 103
  • Yes, unfortunately we hit the DB from PHP as well, so I will probably have to change it manually. It's just strange that South can't change the default. ;-) – MontyThreeCard May 17 '11 at 13:37
  • What I did is basically comment the field, schemamigration / migrate and uncomment again. My database was empty anyway – Mc- Apr 04 '12 at 16:20