Django | 模型類變更后生成遷移文件,報錯:You are trying to add a non-nullable field 'BookName' to BookInfo without a default....


報錯:

You are trying to add a non-nullable field 'BookName' to BookInfo 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) Quit, and let me add a default in models.py

 

原因:

在模型類中添加了一個非空字段,而該模型類對應的表中,已經存在數據,而這些現存的數據並沒有新增字段的值

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM