views:

95

answers:

1

Renaming a simple charfield etc seems easy (http://stackoverflow.com/questions/3235995/django-how-to-rename-a-model-field-using-south)

However when I try using the same on a ForeignKey field I get an error:

_mysql_exceptions.OperationalError: (1091, "Can't DROP '[new_fkey_field_name]'; check that column/key exists")

Which stems from the migration trying to run the backwards for some reason (as evidenced in the trace).

Any ideas?

A: 

When renaming a ForeignKey, remember to add '_id' to the end of the field name you use in Django. E.g.

db.rename_column('accounts_transaction', 'operator_id', 'responsible_id')

And not db.rename_column('accounts_transaction', 'operator', 'responsible')

But I have only tested this on sqlite (which don't actually have the ALTER_TABLE at all), so I don't know if it will actually work on mysql/psotgres:(

Sindre R Myren