django syncdb and an updated model

后端 未结 7 1352
暗喜
暗喜 2020-12-22 18:43

I have recently updated my model, added a BooleanField to it however when I do python manage.py syncdb, it doesn\'t add the new field to the database for the mo

7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-22 19:20

    Django currently does not do this automatically. Your options are:

    1. Drop the table from the database, then recreate it in new form using syncdb.
    2. Print out SQL for the database using python manage.py sql (appname), find the added line for the field and add it manually using alter table SQL command. (This will also allow you to choose values of the field for your current records.)
    3. Use South (per Dominic's answer).

提交回复
热议问题