django修改models重建数据库

时间:2021-07-30 08:25:56

第二次修改models.py以后再次  

python manage.py makemigrations
提示如下

You are trying to add a non-nullable field 'address' to xc_users without a default; we can't do that (the database needs something to populate existing rows). Please select a fix:  1) Provide a one-off default now (will be set on all existing rows)  2) Qu

于是删除数据库表,继续报相同的错误

makemigration需要指定名称,然后migrate才能识别两次<span style="font-family: Arial, Helvetica, sans-serif;">makemigrations的不同</span>

python manage.py makemigrations --name sqlname
 
然后再执行:
python manage.py migrate
成功解决问题