Skip to content

Instantly share code, notes, and snippets.

@realsby
Last active October 2, 2018 07:46
Show Gist options
  • Save realsby/a3984a71072b7221540cb58f9aae7453 to your computer and use it in GitHub Desktop.
Save realsby/a3984a71072b7221540cb58f9aae7453 to your computer and use it in GitHub Desktop.
South Migration Notes

Using south

  1. setup the model

python manage.py schemamigration models --initial

  1. dump data if you have to

python manage.py dumpdata -e contenttypes -e auth.Permission --natural > data.json

  1. syncdb

python manage.py syncdb

python manage.py migrate models

  1. load the data back into the db

python manage.py loaddata data.json

  1. Afterwards, you may use

python manage.py schemamigration models --auto

python manage.py migrate models

after every change you made in the models schema

A few notes

  1. Unloading the database and reload it is essential, because if not doing so the first migration will tell you already have those models.
  2. The -e contenttypes -e auth.Permission --natural parameter in dumpdata is essential otherwise exception will be thrown when doing loaddata.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment