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

- 62,315
- 79
- 204
- 279
-
17The fact that Django doesn't support such a fundamental thing out of the box kept me from using it to create models at all. The fact that they consider an ORM that handles table creation but not (in-place) table modification to be release-quality almost kept me from using Django entirely. – Glenn Maynard Oct 22 '09 at 09:28
-
3The fact that Django allows such great app pluggability makes Django awesome, and renders it's lack of built-in support for table modification basically irrelevant. How hard is installing an app? – Dominic Rodger Oct 22 '09 at 09:34
-
@Glenn, plan your models properly during your design phase and you won't have this problem. If you're adding new features then use a migration suite like South. In-place migrations are often complicated; far too complicated for a simple Django management command anyways. – Soviut Oct 23 '09 at 03:22
7 Answers
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.

- 97,747
- 36
- 197
- 212
-
1Note: I had problem using South for migrating models with a custom db backend (like django-mssql) – Don Apr 04 '11 at 07:32
-
1
Django currently does not do this automatically. Your options are:
- Drop the table from the database, then recreate it in new form using syncdb.
- Print out SQL for the database using
python manage.py sql (appname)
, find the added line for the field and add it manually usingalter table
SQL command. (This will also allow you to choose values of the field for your current records.) - Use South (per Dominic's answer).
Follow these steps:

- 88,194
- 49
- 192
- 260
-
A complete drop and reload for something that should be done in-place? That's terrible. – Glenn Maynard Oct 22 '09 at 09:19
-
3Its a simple management command, not a migration suite! Django has no way of predicting how your data has changed or how to preserve it so it insists that you do it yourself. If you don't like it, use a migration tool like South. – Soviut Oct 23 '09 at 03:21
As suggested in top answer, I tried using South, and after an hour of frustration with obscure migration errors decided to go with Django Evolution instead.
I think it's easier to get started with than South, and it worked perfectly the first time I typed ./manage.py evolve --hint --execute
, so I'm happy with it.

- 1
- 1

- 264,556
- 84
- 409
- 511
-
7After having used Django Evolution and South for almost a year, I'm changing my opinion. South is awesome. But it's very much like Git in the sense **you have to make sure you *really* understand how it works**. If you're typing commands blindly, you'll most likely screw up the first time you or someone on your team makes a mistake. – Dan Abramov Feb 27 '12 at 09:08
Havent used django in a while, but i seem to remember that syncdb does perform alter commands on db tables. you have to drop the table then run again and it will create again.
edit: sorry does NOT perform alter.

- 733
- 4
- 8
-
Then it's not running `alter table` commands, it's running `create table` commands. – Dominic Rodger Oct 22 '09 at 08:09
-
well I have data in the db so it would be great if I overcome this problem without dropping. – Hellnar Oct 22 '09 at 08:09
-
1I think you wanted to say, that syncdb doesNOT perform alter commands. You do not have to drop the table, you can manually add the new field to your sql too. – Odif Yltsaeb Oct 22 '09 at 08:10
-
yes but the question was referencing the use of syncdb, so in this case you would have to drop the table to use syncdb or use the plugin mentioned below. – Alex H Oct 22 '09 at 08:28
-
1If you are frustrated with South, try Django Evolution instead. Worked nice for me. http://stackoverflow.com/questions/1605662/django-syncdb-and-an-updated-model/6127375#6127375 – Dan Abramov May 26 '11 at 08:54
In django 1.6
At first we have run -
python manage.py sql <app name>
Then we have to run -
python manage.py syncdb

- 3,874
- 10
- 53
- 60

- 103
- 2
- 9
If you run Django with Apache and MySQL, restart apache after making migration with makemigrations.

- 1
- 2