错误原因:

语句中缺少默认值

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. 使用require.context实现优雅的预加载

    前言 在前端开发中,对页面花里胡哨度[注1]要求越高的页面,用到的图片.音频什么的就越多,比如什么结婚请柬.展会请柬.发布会宣传页.数据大屏.虽然现在浏览器不允许网页在没有用户交互的情况下播放音频,但 ...

  2. [转] Windows下Hook DirectX

    首先说,这篇文章是很久以前为了玩成某游戏的HOOK找到的资料,虽然一直没用上,但是还是让我保留下来了.直接贴上了..看不懂也不要问我,我都没看. 也许看得懂的人对他们来说这是一个思路,不懂的就当垃圾文 ...

  3. 2022-05-23:给定一个数组arr,你可以随意挑选其中的数字, 但是你挑选的数中,任何两个数a和b,必须Math.abs(a - b) > 1。 返回你最多能挑选几个数。 来自美团。

    2022-05-23:给定一个数组arr,你可以随意挑选其中的数字, 但是你挑选的数中,任何两个数a和b,必须Math.abs(a - b) > 1. 返回你最多能挑选几个数. 来自美团. 答案 ...

  4. vue全家桶进阶之路46:Vue3 Axios拦截器

    在Vue.js 3中,使用Axios与Vue.js 2.x中类似,但是需要进行一些修改和更新,下面是Vue.js 3中Axios的定义和使用方式: 首先,你需要安装Axios和Vue.js 3.x,可 ...

  5. vue一直处在2.9.6版本卸载不了升级不了解决方案

    直接 win+R打开cmd窗口运行命令: 输入where vue,找到vue安装位置,把找到的文件删掉 再执行一次npm uninstall vue-cli -g, vue -V,已经没有版本号了 此 ...

  6. HNU2019 Summer Training 3 E. Blurred Pictures

    E. Blurred Pictures time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. 多线程合集(三)---异步的那些事之自定义AsyncTaskMethodBuilder

    引言 之前在上一篇文章中多线程合集(二)---异步的那些事,async和await原理抛析,我们从源码去分析了async和await如何运行,以及将编译后的IL代码写成了c#代码,以及实现自定义的Aw ...

  8. 【原创】浅谈EtherCAT主站EOE(上)-EOE网络

    这篇文章的标题虽然是关于EtherCAT EOE,但其实主要内容是关于整个EOE网络结构,属于计算机网络原理.而EtherCAT EoE只是简单介绍,并不是文章的重点.需要注意的是,我们的描述主要基于 ...

  9. Python 中常见的 TypeError 是什么?

    翻译:BioIT 爱好者原文:TypeError: A Bytes-Like object Is Required, not 'str' | Finxter 简介 目标:在本教程中,我们的目标是修复以 ...

  10. Road

    首先进行端口扫描22 80 使用nmap进行vuln nmap -sS --script=vuln 10.10.236.244 10.10.236.244/v2/admin/login.html 随便 ...