I use south to migrate my django models. There is however a nasty bug in south. It doesn\'t set default values in Postgres Databases. Example:
created_at = model
As mentioned in earlier answers, the default mechanism in django is implemented in the model class, and is not relevant to south migrations.
Also, since south 0.8, the keep_default flag is deprecated, and won't add the default value to your model.
What I do to solve this is writing a custom migration to add the default value. You can do that by creating a separate data migration:
./manage.py datamigration your_app_name migration_name
and add the following line to the forwards
function:
orm.YourModel.objects.update(field_name = DEFAULT_VALUE)
Alternatively, instead of creating a new migration, you can modify your original migration:
no_dry_run = True
to the class itself (so you will have access to the ORM).orm.YourModel.objects.update(field_name = DEFAULT_VALUE)
to the end of the forwards
function.This way you don't have to write a backwards migration, because you already have the original delete-column one.