$ 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,
重新生成数据

随机推荐
- The Maze II
There is a ball in a maze with empty spaces and walls. The ball can go through empty spaces by rolli ...
- #【Python】【demo实验34】【练习实例】【设置文本的颜色】
原题: 文本颜色设置. 我的代码 #!/usr/bin/python # encoding=utf-8 # -*- coding: UTF-8 -*- # 文本颜色设置. class bcolors: ...
- LC 202. Happy Number
问题描述 Write an algorithm to determine if a number is "happy". A happy number is a number de ...
- MCMF最大流最小割(模板)Dijkstra负权优化
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); #include <cstdio>//sprintf islower isupp ...
- 操作系统diy-1-资料整理
已经研三了,前段时间校招找了份内核开发的工作,正好有时间做这个以前一直想做的事情.听说写操作系统要花很多时间了解学习计算机方方面面的知识,之前也查过相关的资料,关注过mit的操作系统公开课程.这几天准 ...
- 消息服务百科全书——High Availability
1.1为何需要Replication 在Kafka在0.8以前的版本中,是没有Replication的,一旦某一个Broker宕机,则其上所有的Partition数据都不可被消 费,这与Kafka数据 ...
- 常用bat文件
rmLog.bat @echo offpause >nul | echo 按任意键继续3pause >nul | echo 按任意键继续2pause >nul | echo 按任意键 ...
- winfrom_关于打印小票
1.使用的是PrintDocument控件,在工具箱 ,将其托到窗体上: 2. private void btnprint_Click(object sender, EventArgs e) { p ...
- php.ini中allow_url_fopen和allow_url_include的设置
all_url_include在php 5.2以后添加,安全方便的设置(php的默认设置)为:allow_url_fopen=on;all_url_include=off;allow_url_fope ...
- .net Core 图片验证码 基于SkiaSharp实现
public class ImageCaptcha { /// <summary> /// 干扰线的颜色集合 /// </summary> private List<SK ...