错误原因:

语句中缺少默认值

class Main(models.Model):
img = models.CharField(max_length=255)
name = models.CharField(max_length=64)
trackid = models.IntegerField(default=1) class Meta:
abstract = True

解决方案:

在语句中添加任意的默认值,之后再执行ORM迁移指令:

class Main(models.Model):
img = models.CharField(max_length=255, default='1')
name = models.CharField(max_length=64, default='1')
trackid = models.IntegerField(default=1) class Meta:
abstract = True

Django: You are trying to add a non-nullable field 'name' to mainnav without a default; we can't do that (the database needs something to populate existing rows).的更多相关文章

  1. $ 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 ...

  2. Django model :add a non-nullable field 'SKU' to product without a default; we can't do that

    You are trying to add a non-nullable field 'SKU' to product without a default; we can't do that (the ...

  3. Django数据库操作中You are trying to add a non-nullable field 'name' to contact without a default错误处理

    name = models.CharField(max_length=50) 执行:python manage.py makemirations出现以下错误: You are trying to ad ...

  4. Django | 模型类变更后生成迁移文件,报错:You are trying to add a non-nullable field 'BookName' to BookInfo without a default....

    报错: You are trying to add a non-nullable field 'BookName' to BookInfo without a default; we can't do ...

  5. 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 ...

  6. How do I add a Foreign Key Field to a ModelForm in Django?

    What I would like to do is to display a single form that lets the user: Enter a document title (from ...

  7. Python之路【第十七篇】Django进阶篇

    规范 确立规范的好处: 代码可读性高 方便代码的定位极其查找 为以后代码扩容带来便利 场景: 在多个APP的场景下,单个app的URL函数功能较多的时候,我们可以通过以下方法来解决. 把Views写成 ...

  8. Django补充及初识Ajax

    Django创建一对多表结构 首先现在models.py中写如下代码: from django.db import models # Create your models here. class Bu ...

  9. django常见小问题收集(转)

    1.当我把 DEBUG = True设为False的时候运行 python manage.py runserver 的时候 报错 : CommandError: You must set settin ...

  10. Django基础——Model篇(一)

    到目前为止,当程序涉及到数据库相关操作时,我们一般都会这么操作:    (1)创建数据库,设计表结构和字段    (2)使用MySQLdb来连接数据库,并编写数据访问层代码    (3)业务逻辑层去调 ...

随机推荐

  1. 一个好用的java图片缩放及质量压缩方法

    本文中代码来自:http://blog.csdn.net/liuhuanchao/article/details/50527856由于网站需要对上传的图片进行宽度判断缩放和质量压缩,以提升整体加载速度 ...

  2. 配置pip源

    1.使用配置文件配置文件[global]trusted-host=pypi.doubanio.comindex-url=https://pypi.doubanio.com/simple配置文件放置位置 ...

  3. 代码随想录算法训练营Day55 动态规划

    代码随想录算法训练营 代码随想录算法训练营Day55 动态规划| 392.判断子序列 115.不同的子序 392.判断子序列 题目链接:392.判断子序列 给定字符串 s 和 t ,判断 s 是否为 ...

  4. 【LeetCode双向链表】LRU详解,双向链表实战

    LRU缓存 请你设计并实现一个满足 LRU (最近最少使用) 缓存 约束的数据结构. 实现 LRUCache 类: LRUCache(int capacity) 以 正整数 作为容量 capacity ...

  5. Isito 入门:为什么学 Istio、Istio 是什么

    1,Istio 概述 聊聊微服务设计 似乎用上 Kubernetes ,就是微服务系统了. 碰到很多人或公司盲目崇拜 Kubernetes ,一直喊着要上 Kubernetes,但是本身既没有技术储备 ...

  6. 解读与用户一起“跳动”的开源实时监控工具 HertzBeat

    摘要:开源项目遇上华为云,会擦出怎样的火花? 在本期<开源实时监控工具HertzBeat如何与用户一起"跳动?>的主题直播中,HertzBeat & TanCloud 创 ...

  7. 远程desk工具利用总结

    NO.1 Todesk 根据目标软件安装情况有以下两种利用方法 1.目标机已有完整版todesk. 1)改配置文件. 老版本可替换至本地查看密码(此法在最近更新的几个版本中已经失效),新版本只可更改密 ...

  8. 2个场景实例讲解GaussDB(DWS)基表统计信息估算不准的处理方案

    摘要:通过2个实例场景讲解GaussDB(DWS)运维解决方案. 本文分享自华为云社区<GaussDB(DWS)运维 -- 基表统计信息估算不准的常见场景及处理方案>,作者:譡里个檔. 场 ...

  9. 写一个Python简单的Socket网络通讯

    完成需求 用Python完成一个简单的Socket通讯实例 1. 服务端 用于提供服务 源码: import socket s = socket.socket() # 创建服务器端套接字 # sk.s ...

  10. Hugging News #0616: 有几项非常重要的合作快来围观、最新中文演讲视频回放发布!

    每一周,我们的同事都会向社区的成员们发布一些关于 Hugging Face 相关的更新,包括我们的产品和平台更新.社区活动.学习资源和内容更新.开源库和模型更新等,我们将其称之为「Hugging Ne ...