Tuesday, November 18, 2014

Changing fieldnames with django 1.7

It took me a little searching to learn how to do this.  Unlike most migrations, django can't generate name changes automatically.

StackOverflow has a recipe for changing the name of a model and a couple of fields:

http://stackoverflow.com/questions/25091130/django-migration-strategy-for-renaming-a-model-and-relationship-fields

I simplified that recipe for the case when you only want to change a single field name:

https://gist.github.com/dhbradshaw/e2bdeb502b0d0d2acced

No comments:

Post a Comment