Django关联数据库时报错TypeError: __init__() missing 1 required positional argument: 'on_delete'
sgrade = models.ForeignKey("Grades",)
执行python manage.py makemigrations后出现
TypeError: __init__() missing 1 required positional argument: 'on_delete'
缺少一个参数 'on_delete'
加上就好了
sgrade = models.ForeignKey("Grades",on_delete=models.CASCADE,)
Django关联数据库时报错TypeError: __init__() missing 1 required positional argument: 'on_delete'的更多相关文章
- 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 ...
- 执行python manage.py makemigrations时报错TypeError: __init__() missing 1 required positional argument: 'on_delete'
在执行python manage.py makemigrations时报错: TypeError: __init__() missing 1 required positional argument: ...
- Django在根据models生成数据库表时报错: __init__() missing 1 required positional argument: 'on_delete'
原因: 在django2.0后,定义外键和一对一关系的时候需要加on_delete选项,此参数为了避免两个表里的数据不一致问题,不然会报错:TypeError: __init__() missing ...
- Django 生成数据库表时的报错TypeError: __init__() missing 1 required positional argument: 'on_delete'
原因及解决办法: https://www.cnblogs.com/phyger/p/8035253.html
- Django问题 TypeError: __init__() missing 1 required positional argument: 'on_delete'
问题:在执行python manage.py makemigrations learning_logs时,系统会报错,提示:TypeError: __init__() missing 1 requir ...
- python进行数据库迁移的时候显示(TypeError: __init__() missing 1 required positional argument: 'on_delete')
进行数据库迁移的时候,显示 TypeError: __init__() missing 1 required positional argument: 'on_delete' 图示: 出现原因: 在 ...
- Django报错:__init__() missing 1 required positional argument: 'on_delete'
原因: 在django2.0后,定义外键和一对一关系的时候需要加on_delete选项,此参数为了避免两个表里的数据不一致问题,不然会报错:TypeError: __init__() missing ...
- 【python3】 django2.0 在生成数据库表时报错: TypeError: __init__() missing 1 required positional argument: 'on_delete'
python: 3.6.4 django: 2.0 models.py 代码如下 # coding: utf-8 from django.db import models from django.co ...
- TypeError: __init__() missing 1 required positional argument: 'on_delete'
报错的原因呢,就是在设计model时我弄了个外键,然后就报错了... 不难看出,它是想让我们在表与表关联时添加一个on_delete参数 解决办法: 如其所愿,加上on_delete=models.C ...
随机推荐
- ToastUtils 工具类
package com.example.grenaderose.redthunder.utils; import android.content.Context; import android.os. ...
- Linux console 重定向
Linux从启动到启动完成的所有输出均复制到Com口上,一共需要修改3个文件.在此之前还要确认/sbin/agetty文件是否存在,此文件用来把系统的输入输出映射到其它设备上. 1.首先在 /etc/ ...
- 原生js简单轮播图 代码
在团队带人,突然被人问到轮播图如何实现,进入前端领域有一年多了,但很久没自己写过,一直是用大牛写的插件,今天就写个简单的适合入门者学习的小教程.当然,轮播图的实现原理与设计模式有很多种,我这里讲的是用 ...
- 在centos7 部署bbr
How to Deploy Google BBR on CentOS 7 Published on: Thu, Jan 5, 2017 at 6:34 pm EST CentOS Linux Guid ...
- Dynamics AX 中的图片处理
1.从本地读取图片文件,并判断格式是否附合要求. FilenameFilter filter = [‘Image Files‘,‘*.bmp;*.jpg;*.gif;*.jpeg‘]; BinData ...
- vue生命周期-mounted和created的区别
详情请查看:https://blog.csdn.net/xdnloveme/article/details/78035065 自己做个总结: beforeCreate 创建之前:已经完成了 初始化事件 ...
- python中print不换行
python中的print打印的结果总是进行了换行,如果不想换行显示可以在print中添加“end ='' ” 一般print显示: for i in range(3): print(i) #显示结果 ...
- union: apt command
# when you use 'dpkg -i $software' failed, you can install the dependency of this software by # this ...
- 【Python】 Python3 环境搭建
Python是一种计算机程序设计语言.是一种面向对象的动态类型语言,最初被设计用于编写自动化脚本(shell),随着版本的不断更新和语言新功能的添加,越来越多被用于独立的.大型项目的开发. Windo ...
- spring boot 注解
一级注解:(写在类名前面的)@RestController: 等价于在函数前面写@ResponseBody ,会直接返回要显示的内容 @ControllerString返回的是模板文件的名称. 二级注 ...