What is the best way to migrate data in django

hamdiakoguz picture hamdiakoguz · Oct 6, 2008 · Viewed 21.3k times · Source

After making some changes in my models (eg. new field in a model and a new model) what is the best way of reflecting these changes to my populated database?


PS: I wanted to see many solutions in one place rated. Apparently more solutions are already listed here.

Answer

shacker picture shacker · Oct 16, 2008

Another technique is to use the dumpdata and loaddata arguments to manage.py, killing your database in-between:

  1. python manage.py dumpdata > dump.json
  2. With an external tool, drop any affected tables, or kill the whole db
  3. python manage.py loaddata dump.json

See manage.py docs for more.