wiki:FAQ

Version 4 (modified by andrew, 5 years ago) (diff)

--

Frequently Asked Questions

If you have a question you think needs to go on here, then get in touch.

Why does my migration with both column changes and data changes fail?

You can't edit the columns and the data in them in the same transaction, and since all migrations are wrapped in transactions your database will complain. See Migration Structure: Transactions for more, and an example of how to start a new transaction.

Why does South keep claiming my migration doesn't exist, when it does?

This is probably because you have an ImportError? in your migration; South can't distinguish between this and a missing migration. See #29.

Why can't I use --add-field with a ManyToMany? field that uses a 'through' model?

It's your responsibility to create the interim table manually, since South can't really tell if it's there or not. Just use ./manage.py startmigration appname migrationname --model ThroughModelName instead.

I can't alter/delete my ForeignKey? column, it claims it doesn't exist.

Remember that ForeignKey? columns have an extra _id at the end of their name; you don't need to specify this in add_column, but you do in alter_column and delete_column, as we can't infer it there.

Passing a field with unique=False to alter_column doesn't remove that column's UNIQUE constraint.

No, it doesn't, you need to use delete_index instead, like so:

db.delete_index("tablename", ["columnname"])

If you still want an index on that column, but don't want it to be unique, you'll need to drop and create the index without unique=True (which is a valid argument to create_index, should you need to create a unique index).