首页 > 其他 > 详细

Django | 模型类变更后生成迁移文件,报错:You are trying to add a non-nullable field 'BookName' to BookInfo without a default....

时间:2019-02-27 21:31:52      阅读:900      评论:0      收藏:0      [点我收藏+]

报错:

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

 

原因:

在模型类中添加了一个非空字段,而该模型类对应的表中,已经存在数据,而这些现存的数据并没有新增字段的值

 

 

 

 

Django | 模型类变更后生成迁移文件,报错:You are trying to add a non-nullable field 'BookName' to BookInfo without a default....

原文:https://www.cnblogs.com/qiutenglong/p/10446888.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!