Search code examples
pythondjangomigrationschemadjango-south

South/Django: Schema migrations default value for existing entries


I want to add a BooleanField to an existing model, with default=False and that all already existing objects in my table get a True value in that field.

This is: I want all my existing objects to have my new attribute on True, but from now every new object has this value at False by default.

I tried rolling back my migration, setting the "keep_default" on True, migrate again but it didn't work.

Thanks


Solution

  • Add the new field with default=False, create the schemamigration as usually --auto and run it, then code a datamigration for changing the value to True for all existing objects and run it, that is all :D