I need to rename a foreign key in my django model using south migrations. I thought I was in luck when I found this thread How to rename a foreignkey field with South? However, all the methods described there fail, with various errors. Does someone actually know the proper way to do this?
I want to rename SomeModel.registered_to = models.ForeignKey( User ) to SomeModel.owner = models.ForeignKey( User ) and keep the relation between User and owner Any help would be appreciated!
Change the field name and run
python manage.py schemamigration --auto yourapp. South will add code to drop the column and add a new one. Letting South generate the migration ensures that the ORM is frozen properly, so all you need to do is just change the actual migration to rename instead of drop and add. Just remove those lines from the forwards and backwards migration to and replace them with:Save, and then migrate your app.