Search code examples
pythondjangodjango-modelsdjango-south

Django South editing field names in model with --auto --update


In the South Docs,when changing the name of a field it wants you to use ./manage.py schemamigration southtut --auto --update. When I use it I get the following./manage.py: error: no such option: --update. also when checking the possible options I can use update is not in there.

options given:

--add-field= --add-model= --empty --help --pythonpath= --stdout --verbosity= --add-index= --auto --freeze= --initial --settings= --traceback


Solution

  • Is simple, do it without --update. When you issue schemamigration southtut --auto it should automatically acknowledge the changes and notice that a field has changed a name and do what it has to.

    It has worked for me.

    Besides what --update does is update the last migration instead of creating a new one so is probably not what you want. What you want is to change the schema.

    If you want to rename a field in the model, you probably will have to dome something like create a migration that add the new field with the new name, then create a data migration to add the data from the old field (the one you wanna change the name) to the new field (the one with the new name) and then create a third migration to remove the old column.

    You can search how to do data migration in the south doc.

    You can try also what it is in this very good answer. It might be simpler.

    Hope it helps.