Reputation: 673
I have an application in Django 1.6.5. I have a model where I removed one field, I added another field, and the third upgraded. And when we now turn to the model in the admin panel, I get the message:
ProgrammingError at /admin/app/subscription/
column app_subscription.enabled does not exist
The command python manage.py syncdb
does not work.
Upvotes: 1
Views: 666
Reputation: 21
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
Upvotes: 0
Reputation: 77932
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:
syncdb
. This mean you will loose all our data, so it's hardly a "solution" 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
Upvotes: 2