zoukankan      html  css  js  c++  java
  • $ python manage.py makemigrations You are trying to add a non-nullable field 'name' to course without a default; we can't do that (the database needs something to populate existing rows). Please selec

    问题:

    $ python manage.py makemigrations
    You are trying to add a non-nullable field 'name' to course 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

    原因:由于之前已经存在的表,某些字段为没有默认值,这时候添加的时候,需要给定默认值

    解决:

    方法1:每个报错的字段添加   

    blank=True, null=True

    方法2:需要添加的字段太多,

             本地自己做项目的话,

           删除之前的数据库,删除migrations,

         重新生成数据

  • 相关阅读:
    IDEA效率快捷键
    常用文件/文件夹操作
    git log状态下退出方法
    ImageList 构造函数
    ImageList 控件
    【转】图像分割代码合集
    【转】图像分割论文及代码资源汇总
    SLIC 算法
    c/c++内存分配详解
    c++内存分配
  • 原文地址:https://www.cnblogs.com/venicid/p/11922861.html
Copyright © 2011-2022 走看看