DjangoModels修改后出现You are trying to add a non-nullable field 'download' to book without a default; we can't do that (the database needs something to populate existing rows). Please select a fix:

这个问题是在模型中新添加的,在原来已经有的表单中没有值。所以在新添加的值得括号中添加

  1 download = models.ForeignKey(Download, on_delete=models.CASCADE, null=True)


然后

  1 python manage.py makemigrations
  2 
  3 python manage.py migrate
posted @ 2020-07-09 08:50  ACWink  阅读(2524)  评论(0编辑  收藏  举报