[Answered ]-Column does not exist in django 1.6.5

2đź‘Ť

Django (hopefully) doesn’t modify your database schema if you don’t explicitely ask for it. The syncdb command works perfectly, but (as documented) it will only create tables that don’t yet exists (and are not marked as being managed externally in your models).

So you have mostly three options here:

  1. manually drop your table and re-run syncdb. This mean you will loose all our data, so it’s hardly a “solution”
  2. manually alter your database schema. You won’t loose your data, but you’ll have to repeat the same (manual) operation everywhere your app is deployed… If it’s only installed on your local workstation that might be ok, else it’s not a reliable professional production-level option.
  3. Use South (which seems to be installed since you do have a migrate command available.

Note that solution #3 imply that you do create the migration files for your app, as documented here : http://south.readthedocs.org/en/latest/tutorial/part1.html#the-first-migration

0đź‘Ť

It just happened that I faced the same issue with django 1.9.x, where I added a new field in my django app which triggered the same error as you mentioned above.
I logged into the dbshell environment using

python manage.p dbshell # I know some use ./manage.py

and dropped all of my tables by running the following command within the dbshell to drop the tables

your_psql=# drop schema public cascade;

This will drop all of your tables (be careful as you may lose your data, there away to keep the data!) and you will get a message right after executing this command tells you that all dropped. Right after that run the following command to create the schema again, otherwise your server will not run:

your_psql=# create schema public;

Then just do the

python manage.py makemigrations # you might not need this, and 
python manage.py migrate

And you’re ready to go.

I know this answer might be very late but I hope it will help someone.

Cheers

👤Berkelian

Leave a comment