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,应用里面创建的 ...
随机推荐
- STM32启动文件详解
启动文件使用的 ARM 汇编指令汇总 启动程序源码注释(点此下载) 1. Stack—栈 Stack_Size EQU 0x00000400 AREA STACK, NOINIT, READWRITE ...
- python中检测某个变量是否有定义
目录 第一种方法使用内置函数locals() 第二种方法使用内置函数dir() 第三种方法使用内置函数vars() 第一种方法使用内置函数locals() 'testvar' in locals(). ...
- 安装v2ra y
说明 全文中所有的‘删掉我’,都请忽略,如果不这么做,那么您将看不到这篇文章 ssr已经不行了,现在大家都以v2ra y为主 安装服务端 运行一键安装脚本,之后进入脚本界面,选“1”安装: bash ...
- Linux通用小技能
Linux通用小技能 前言 无论你用ubuntu还是centos,通通没问题,运维这东西,踩坑写文档就是了. 小技能 新磁盘挂载 不管是阿里云还是腾讯云,还是自己的机器,请记住这条命令. mkfs.e ...
- ...:ES6中扩展运算符(spread)和剩余运算符(rest)详解
1.扩展运算符(spread) demo1:传递数据代替多个字符串的形式 let test= function(a,b,c){ console.log(a); console.log(b); cons ...
- 在.netcore webapi项目中使用后台任务工具Hangfire
安装Hangfire 在webapi项目中通过nuget安装Hangfire.Core,Hangfire.SqlServer,Hangfire.AspNetCore,截止到目前的最新版本是1.7.6. ...
- 傅里叶变换通俗解释及快速傅里叶变换的python实现
通俗理解傅里叶变换,先看这篇文章傅里叶变换的通俗理解! 接下来便是使用python进行傅里叶FFT-频谱分析: 一.一些关键概念的引入 1.离散傅里叶变换(DFT) 离散傅里叶变换(discrete ...
- nexus 匿名用户的问题。
为了做到安全和不浪费我们自己的服务器资源,要绝对拒绝匿名用户进行访问: 1,不允许匿名用户访问 2,禁用匿名的账号 以下是这2点的设置图. ============================== ...
- Android中BroadcastReceiver的使用
1.Android中广播分为静态注册和动态注册 2.下面是一个简单静态注册的例子 创建一个继承BroadcastReceiver的子类 public class DeviceBootReceiver ...
- 基于【 centos7】二 || 系统时间与网络时间同步
# date // 查看系统时间 #hwclock // 查看硬件时间 # yum -y install ntp ntpdate 安装ntpdate工具 # ntpdate cn.pool.ntp.o ...