So I have a model that I wanted to add ImageField to, so I typed in
picture = models.ImageField(upload_to=’media/images’)
I then ran syncdb and went into the shell:
python2 manage.py syncdb
python2 manage.py shell
I then imported the model and tried
"model".objects.get(pk=1)
I get the error:
DatabaseError: no such column: people_people.picture
When I run manage.py sql for the model
"picture" varchar(100) NOT NULL
is in the database.
What solutions do you guys have? I can’t delete the data in the database.
As noted in the documentation
syncdbdoesn’t add columns to existing tables, it only creates new tables.I suggest running
Looking at the sql it outputs for the table you’re changing, and then running
in order to manually issue an
ALTER TABLEcommand.In future, you might like to use a migration tool like South.