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,

         重新生成数据

  • 相关阅读:
    VisualVM工具的使用
    jstack的使用
    JVM内存溢出的定位与分析
    初识JVM
    JVM运行参数
    VIM 常用命令
    python3 简单抓取图片2
    python3 抓取图片
    node.js GET 请求简单案例
    node.js 爬虫
  • 原文地址:https://www.cnblogs.com/venicid/p/11922861.html
Copyright © 2011-2022 走看看