$ 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,
重新生成数据
随机推荐
- [转帖]关于 /dev/urandom 的流言终结 | Linux 中国
关于 /dev/urandom 的流言终结 | Linux 中国 2019年05月05日 14:03:52 技术无边 阅读数 202 版权声明:本文为博主原创文章,遵循CC 4.0 by-sa版权 ...
- 【AtCoder】CODE FESTIVAL 2016 qual B
CODE FESTIVAL 2016 qual B A - Signboard -- #include <bits/stdc++.h> #define fi first #define s ...
- SHE姐妹建模记录
中午11点54分,队长把MD5码提交上去在群里发了截图,我对着屏幕上刚检查完的论文,感觉整个人都轻松起来了,又有点恍惚,可能是这几天都没睡好觉.去楼下吃了顿饭,本来打算回来倒头就睡,睡到几点算几点,醒 ...
- urllib基础
import urllib.request # urlretrieve(网址,本地路径) 直接下载网页到本地 urllib.request.urlretrieve("http://www.b ...
- Centos7搭建在线yum源
1: 首先关闭防护墙或者设置规则通过且关闭selinux Systemctl diablefirewalld 永久关闭防火墙 vim/etc/sysconfig/selinux 并修改SELINUX ...
- C#连接Oracle数据库的方法
目前了解C#中连接Oracle数据库的方法有3种,分布是微软的System.Data.OracleClient,Oracle的Oracle.DataAccess.Client和Oracle的Oracl ...
- JavaScript Basics_Fundamentals Part 1_Variables
JavaScript Variables JavaScript 变量(Variables)是用于存储数据值的容器. 创建一个 JavaScript 变量,可以使用关键字 let. Example le ...
- 让theano在windows下能进行GPU并行的配置步骤
最近在implement DeepLearning.net上面的程序.对于开源的python,最头疼的就是各种package和各种configuration. 而且还是在windows下. 想要让th ...
- R 读取xls/xlsx文件
包readxl install.packages('readxl',repois='https://mirrors.utsc.edu.cn/CRAN/) library(readxl) # read_ ...
- CentOS自动备份MySql
1.确认Crontab是否安装 service crond startcrontab -l 2.编写备份脚本 cd mkdir backup cd backup vim auto.sh /usr/bi ...