问题:

$ 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,

重新生成数据

随机推荐

  1. 1、Ubuntu linux下同步windows火狐foxfire 浏览器收藏夹问题

    最近在ubuntu系统中使用自带的firefox浏览器,发现有一些问题,比如登陆后,书签,历史记录等,原本在windows下同步的数据无法同步,添加书签的功能也无法使用. 经过查询资料后得知,unbu ...

  2. 题解 CF546C 【Soldier and Cards】

    思路 是一道水题,可以用队列+模拟来写,注意不要拿完队列中的元素! 代码 #include<iostream> #include<cstdio> #include<que ...

  3. python 定时爬取内容并发送报告到指定邮箱

    import requests import smtplib import schedule import time from bs4 import BeautifulSoup from email. ...

  4. Python文件操作——读写图片,音频,视频

    注意:其实就是将mode="rb"或者mode="wb",因为图片,视频,音频就是二进制进行读取,b  代表binary ,其他的和一般文件操作步骤一样,另外, ...

  5. # 机器学习算法总结-第一天(KNN、决策树)

    KNN算法总结 KNN算法的核心思想是如果一个样本在特征空间中的k个最相邻的样本中的大多数属于某一个类别,则该样本也属于这个类别.(监督) k近邻算法(knn)是一种基本的分类与回归的算法,k-mea ...

  6. IDEA GIT 忽略文件

    1.装插件 .igore 2.新建忽略文件格式 3.编辑忽略后缀文件 可以是文件夹 也可以是 具体文件类型

  7. 18.SSM整合_搭建开发环境

    1.导入jar包 mybatis的Jar包 ehcache的Jar包 spring的 Jar包 mybatis 与 spring 整合Jar包 JSON的jar包 Jaskson的Jar包 Hiber ...

  8. Yii 2.0 GII 访问404错误

    网上大部分都是普通的开启和配置资料 按照网上资料配置 访问localhost/index/php?r=gii 总是提示404错误 解决方法如下: Yii基础版中的 web.php 代码如下 if (Y ...

  9. axios替换jquery的ajax

    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.js"></script> <scr ...

  10. list 列表 函数的引用

    方法 意义 L.index(v [, begin[, end]]) 返回对应元素的索引下标, begin为开始索引,end为结束索引,当 value 不存在时触发ValueError错误 L.inse ...