python manage.py makemigrat 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
更新models字段

出现的问题:
$ python manage.py makemigrations
None
You are trying to add a non-nullable field 'file_type' to filejinja without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix:
) Provide a one-off default now (will be set on all existing rows with a null value for this column)
) Quit, and let me add a default in models.py
Select an option:
原因:

之前数据表里面已经存在,如果添加,file_type需要默认值
解决:
方法1:
在model字段后面添加,
blank=True, null=True
file_type = models.CharField(verbose_name="文件type", max_length=, choices=(
('', "配置文件"),
('', "sls文件"),
), blank=True, null=True)
再执行
$ python manage.py makemigrations
None
Migrations for 'minions':
apps\minions\migrations\0011_filejinja_file_type.py
- Add field file_type to filejinja

方法2:
数据库中找到django_migrations,该表对应,每次makemigrations的每次记录

删除,生成的migrations
在删除你要更新的表。

重新生成新的表
$ python manage.py makemigrations
None
Migrations for 'minions':
apps\minions\migrations\0010_filejinja.py
- Create model FileJinja liangshuo@zt- MINGW64 /f/11_goms/goms (master)
$ python manage.py migrate
None
Operations to perform:
Apply all migrations: admin, auth, contenttypes, minions, salt, sessions
Running migrations:
Applying minions.0010_filejinja... OK

python manage.py makemigrat 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的更多相关文章
- $ 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 makemigrationsYou are trying to add a non-nullable field 'name' to course wit ...
- 【解决方案】django初始化执行python manage.py migrate命令后,除default数据库之外的其他数据库中的表没有创建出来
[问题原因]:django工程中存在多个应用,每个应用都指定了对应的数据库.执行python manage.py migrate命令时没有指定数据库,将只初始化默认的default数据库. [解决方案 ...
- python manage.py shell之后的一些错误:
1. 在执行python manage.py shell之后的一些错误: wyl@wyl:~/myobject$ python manage.py shell /usr/lib/python2.7/d ...
- Python Django CMDB项目实战之-2创建APP、建模(models.py)、数据库同步、高级URL、前端页面展示数据库中数据
基于之前的项目代码来编写 Python Django CMDB项目实战之-1如何开启一个Django-并设置base页index页文章页面 现在我们修改一个文章列表是从数据库中获取数据, 下面我们就需 ...
- django源码分析 python manage.py runserver
django是一个快速开发web应用的框架, 笔者也在django框架上开发不少web应用,闲来无事,就想探究一下django底层到底是如何实现的,本文记录了笔者对django源码的分析过程 I be ...
- django(python manage.py imgrate)同步数据库出错后的解决办法
问题 很多情况下,因为app的models.py的文件内容有误,但是通过python manage.py check检查不出来时,当执行python manage.py migra ...
- python manage.py syncdb Unknown command: 'syncdb'问题解决方法
在django1.9后的版本中,python manage.py syncdb命令修改为python manage.py migrate,执行正常. 选择sqlite可视化sqlitestudio-3 ...
- Python 模型定义 :通过pymysql和数据模型(models.py)创建mysql表及表结构
一.model的配置 1.创建数据库 2.安装pymysql 3.修改配置文件 数据库连接配置 DATABASES = { 'default': { 'ENGINE': 'django.db.back ...
- Django 中 python manage.py makemigrations 与 python manage.py migrate
执行 python manage.py makemigrations django根据settings.py里面的INSTALLED_APPS项设置找到对应app里的models.py,应用里面创建的 ...
随机推荐
- 多线程(5) — JDK的并发容器
JDK提供了一些高效的并发容器,下面介绍几个 ConcurrentHashMap:这是个高效的并发HashMap,可以理解为一个线程安全的HashMap. CopyOnWriteArrayList:这 ...
- MySQL的sql语言分类DML、DQL、DDL、DCL
SQL语言一共分为4大类:数据定义语言DDL,数据操纵语言DML,数据查询语言DQL,数据控制语言DCL 1.数据定义语言DDL(Data Definition Language) 对象: 数据库和表 ...
- HTML 前端
昨日内容回顾 HTML文档结构 标签要封闭,全封闭,自封闭 html文件不识别多个空格或者换行,都识别成一个空格 注释: <!-- 注释 --> head标签 网页源信息,配置信息 tit ...
- list列表
list列表 list:一个有序的集合 创建列表 语法格式: 列表名 = [元素1, 元素2, 元素3…….,元素n] 注:列表中的元素⽤逗号隔开. 注:列表⾥⾯的元素可以是不同类型的数据. 列表元素 ...
- docker&k8s-配置/常用命令
kubectl delete deployment,ingress,svc demo-mml-jp-ylmopt-web-1 -n demo-mml #删除预生产环境mml组ylmopt-web ...
- PAT(B) 1021 个位数统计(Java)
题目链接:1021 个位数统计 (15 point(s)) 代码 /** * Score 15 * Run Time 93ms * @author wowpH * @version 1.0 */ im ...
- Vue CLI 3开发中屏蔽的EsLint错误 (.eslintrc.js 在vue3+中 修改这个)
1.关闭eslint校验有了eslint的校验,可以来规范开发人员的代码,是挺好的.但是有些像缩进.空格.空白行之类的规范,在开发过程中一直报错,未免太过于苛刻了.所以,我还是会选择关闭eslint校 ...
- uboot 代码执行顺序
ref:http://blog.chinaunix.net/uid-30352139-id-5128405.html uboot: 2014.07 1.1 U-boot相关文件 boards.c ...
- (二十五)JSP九大内置对象(转)
--转载自孤傲苍狼博客 一.JSP运行原理 每个JSP 页面在第一次被访问时,WEB容器都会把请求交给JSP引擎(即一个Java程序)去处理.JSP引擎先将JSP翻译成一个_jspServlet(实质 ...
- 洛谷 P1047 校门外的树(待完善)
链接:https://www.luogu.org/problemnew/show/P1047 题目: 题目描述 某校大门外长度为L的马路上有一排树,每两棵相邻的树之间的间隔都是11米.我们可以把马路看 ...