在添加外键的时候,在括号里添加on_delete=models.CASCADE即可

on_delete=models.CASCADE是级联删除的意思,意思就是说当你更新或删除主键表,那外键表也会跟随一起更新或删除。

django报错TypeRError:__init__() missing 1 required positional argument: 'on_delete'的更多相关文章

  1. Django报错:__init__() missing 1 required positional argument: 'on_delete'

    原因: 在django2.0后,定义外键和一对一关系的时候需要加on_delete选项,此参数为了避免两个表里的数据不一致问题,不然会报错:TypeError: __init__() missing ...

  2. Django 生成数据库表时的报错TypeError: __init__() missing 1 required positional argument: 'on_delete'

    原因及解决办法: https://www.cnblogs.com/phyger/p/8035253.html

  3. Django :执行 python manage.py makemigrations 时报错 TypeError: __init__() missing 1 required positional argument: 'on_delete'

    原因 执行命令 python manage.py makemigrations 报错 TypeError: __init__() missing 1 required positional argum ...

  4. Django在根据models生成数据库表时报错: __init__() missing 1 required positional argument: 'on_delete'

    原因: 在django2.0后,定义外键和一对一关系的时候需要加on_delete选项,此参数为了避免两个表里的数据不一致问题,不然会报错:TypeError: __init__() missing ...

  5. Django关联数据库时报错TypeError: __init__() missing 1 required positional argument: 'on_delete'

    sgrade = models.ForeignKey("Grades",) 执行python manage.py makemigrations后出现TypeError: __ini ...

  6. 执行python manage.py makemigrations时报错TypeError: __init__() missing 1 required positional argument: 'on_delete'

    在执行python manage.py makemigrations时报错: TypeError: __init__() missing 1 required positional argument: ...

  7. Django在根据models生成数据库表时报 __init__() missing 1 required positional argument: 'on_delete'

    from django.db import models # Create your models here. class Category(models.Model): caption = mode ...

  8. Django问题 TypeError: __init__() missing 1 required positional argument: 'on_delete'

    问题:在执行python manage.py makemigrations learning_logs时,系统会报错,提示:TypeError: __init__() missing 1 requir ...

  9. Python3:Django根据models生成数据库表时报 __init__() missing 1 required positional argument: 'on_delete'

    Python3:Django根据models生成数据库表时报 __init__() missing 1 required positional argument: 'on_delete' 一.分析 在 ...

  10. Django2.1在根据models生成数据库表时报 __init__() missing 1 required positional argument: 'on_delete'

    解决办法: a=models.ForeignKey('BookInfo',on_delete=models.CASCADE,) 即在外键值的后面加上 on_delete=models.CASCADE ...

随机推荐

  1. C#projectPropertyGrid 显示结构(展开逗号分隔)

    [TypeConverter(typeof(ExpandableObjectConverter))] public A MyA { get{..} set{..} }

  2. 【php socket通讯】php实现http服务

    http服务是建立在tcp服务之上的,它是tcp/ip协议的应用,前面我们已经实现了tcp服务,并且使用三种不同的方式连接tcp服务 php中连接tcp服务的三种方式 既然http也是tcp应用层的一 ...

  3. springboot2.0(二)

    三. Web开发 3.1.静态资源访问 在我们开发Web应用的时候,需要引用大量的js.css.图片等静态资源. 默认配置 Spring Boot默认提供静态资源目录位置需置于classpath下,目 ...

  4. Go 缓冲信道

    缓冲信道 语法结构:cap为容量 ch := make(chan type, cap) 缓冲信道支持len()和cap(). 只能向缓冲信道发送容量以内的数据. 只能接收缓冲信道长度以内的数据. 缓冲 ...

  5. ASE19团队项目 beta阶段 model组 scrum4 记录

    本次会议于12月5日,19时30分在微软北京西二号楼sky garden召开,持续10分钟. 与会人员:Lei Chai, Linfeng Qi, Xueqing Wu, Yutong Ling (Z ...

  6. BP神经网络—java实现

    神经网络的结构 神经网络的网络结构由输入层,隐含层,输出层组成.隐含层的个数+输出层的个数=神经网络的层数,也就是说神经网络的层数不包括输入层.下面是一个三层的神经网络,包含了两层隐含层,一个输出层. ...

  7. Linux——CentOS7安装gcc编译器详解 查看内核版本

    [root@localhost ~]# uname -a Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Thu Nov 8 23:3 ...

  8. redis slot 槽点

    Redis 集群中内置了 16384 个哈希槽,当需要在 Redis 集群中放置一个 key-value 时,redis 先对 key 使用 crc16 算法算出一个结果,然后把结果对 16384 求 ...

  9. Spring的使用及Spring3.2控制器增强@ControllerAdvice

    在xml配置了这个标签后,spring可以自动去扫描base-pack下面或者子包下面的java文件,如果扫描到有@Component. @Controller.@Service等这些注解的类,则把这 ...

  10. 版本问题---cuda和tensorflow的版本对应关系

    cuda和tensorflow的版本有对应关系 https://tensorflow.google.cn/install/source#linux