DatabaseError: no such column error

后端 未结 3 682
醉话见心
醉话见心 2021-02-02 01:08

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

3条回答
  •  不思量自难忘°
    2021-02-02 01:30

    As noted in the documentation syncdb doesn't add columns to existing tables, it only creates new tables.

    I suggest running

    python manage.py sqlall 
    

    Looking at the sql it outputs for the table you're changing, and then running

    python manage.py dbshell
    

    in order to manually issue an ALTER TABLE command.

    In future, you might like to use a migration tool like South.

提交回复
热议问题