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