django syncdb and an updated model


I have recently updated my model, added a BooleanField to it however when I do python syncdb, it doesn't add the new field to the database for the model. How can I fix this ?

10/22/2009 8:04:52 AM

Accepted Answer

From Django 1.7 onwards

Django has built in support for migrations - take a look at the documentation.

For Django 1.6 and earlier

Django doesn't support migrations out of the box. There is a pluggable app for Django that does exactly that though, and it works great. It's called South.

4/24/2014 5:27:21 AM

Django currently does not do this automatically. Your options are:

  1. Drop the table from the database, then recreate it in new form using syncdb.
  2. Print out SQL for the database using python sql (appname), find the added line for the field and add it manually using alter table SQL command. (This will also allow you to choose values of the field for your current records.)
  3. Use South (per Dominic's answer).

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow