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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM