[Django]-Changing models in django results in broken database?

9👍

Django does not perform database migration for you, i.e., if you add new fields, Django won’t modify your database schema.

You can either:

  1. Drop the tables that changed and perform syncdb again. This is reasonnable when you are developing your application and you don’t have any real data in your database.
  2. Use a migration tool like South that performs database migration (like hibernate update script).
  3. Edit the database by hand and add/delete the appropriate fields for the previously existing tables.

4👍

For me, (so long as you’re doing this with test data, and not doing this in a production environ) it’s alot easier to just blow away the test.db and do a new ./manage.py syncdb. Just food for thought…

2👍

Just to expand on @Barthelemy’s answer, there are several Django migration tools:

Leave a comment