1👍
✅
manage.py syncdb
will only create missing tables. If a table already exists, but with an invalid definition, it will not be updated. This is very probably the problem that you are experiencing.
There are at least three ways to solve the problem.
- The easy way: use
manage.py reset
to effectively drop+recreate all the tables. Easy, but of course you will lose the data. - The lazy way: install
django_extensions
and usemanage.py sqldiff
. It will show you the difference between the current structure of the database, and the expected structure.sqldiff
will nicely show you SQL statements which can update the existing database to conform with your models. You can then execute those statements in a SQL shell. - The clean way: use a migrations framework like
south
to handle database schema updates. Of course, if you are early in the development, this is overkill (you do not want to write database migrations each time you add/change/remove a field while you’re doing local development!) but if your project will have a longer life span, I definitely recommend checking outsouth
.
Source:stackexchange.com