解决You are trying to add a non-nullable field 'hbook' to heroinfo without a default;

1、问题描述

Django在执行迁移文件时出现的错误,即当你在Pycharm下面的Terminal中输入’Python manger.py makemigrations’ 时出现以下错误:

You are trying to add a non-nullable field 'hbook' to heroinfo 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 with a null v
alue for this column)
 2) Quit, and let me add a default in models.py

2、解决方法

删除migrations下的0001_initial.py文件,之后重新在Terminal执行python manage.py makemigrations和python manage.py migrate,重新生成迁移文件。
 

 


版权声明:本文为qq_38418803原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。