每次都害怕增加删除django的models里面的表 , 增加后总是爆出一些错误
$ python manage.py makemigrations
遇到这个问题 :
You are trying to add a non-nullable field 'o_solution' to onlinefaq 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 value for this column)
2) Quit, and let me add a default in models.py
说明 你最后操作的字段 需要添加一个default的默认值 ,这样才可以通过
$ python manage.py migrate 编译的时间总是出错
于是乎心情烦躁 ,就把数据库中新建的这个表给删除了 ,以为在重新创建一次就可以了 ,发现问题依旧 .
解决办法 :
1 . 在数据库中有一个 django_migrations的表 ,最后一次的构建在最后一行, 删除掉 .
2 .在django中migrations中最后一个也是新建的(跟新建有关的都删除掉) ,果断的也删除掉 .
3.重新的migrate下 就可以