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

解决方法:

在连接外键时加上:
on_delete=models.CASCADE
执行python manage.py makemigrations时报错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 ...
- Django关联数据库时报错TypeError: __init__() missing 1 required positional argument: 'on_delete'
sgrade = models.ForeignKey("Grades",) 执行python manage.py makemigrations后出现TypeError: __ini ...
- 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
- python进行数据库迁移的时候显示(TypeError: __init__() missing 1 required positional argument: 'on_delete')
进行数据库迁移的时候,显示 TypeError: __init__() missing 1 required positional argument: 'on_delete' 图示: 出现原因: 在 ...
- Django问题 TypeError: __init__() missing 1 required positional argument: 'on_delete'
问题:在执行python manage.py makemigrations learning_logs时,系统会报错,提示:TypeError: __init__() missing 1 requir ...
- Django报错:__init__() missing 1 required positional argument: 'on_delete'
原因: 在django2.0后,定义外键和一对一关系的时候需要加on_delete选项,此参数为了避免两个表里的数据不一致问题,不然会报错:TypeError: __init__() missing ...
- 解决TypeError: __init__() missing 1 required positional argument: 'on_delete'
试用Djiango的时候发现执行mange.py makemigrations 和 migrate是会报错,少位置参数on_delete,查了一下是因为指定外键的方式不对,改一下就OK了. 代码如下: ...
- 【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 ...
随机推荐
- C语言基础 (5) 常用操作符
01 课程回顾 变量的起名:字母数字下划线 不能是关键字 常量 变量提升:老的编译器这样会报错 运算符:sizeof.+.-.x … … 进制: 1111 8421 计算机几乎都是二进制系统,而且是以 ...
- vue开发基本步骤
1 安装node.js 安装node.js之前,先进行nvm的安装: https://github.com/coreybutler/nvm-windows/releases最好选择稳定版本 ...
- Python for Xpath
# Xpath- 在XML文件中查找信息的一套规则/语言,根据XML的元素或者属性进行遍历 ## Xpath开发工具- 开源的Xpath表达式编辑工具:XMLQuire- Chrome插件:Xpath ...
- CentOS中防火墙相关的命令(CentOS7中演示)
CentOS中防火墙程序主要是firewall和iptables,CentOS7中firewall服务已经默认安装好了,而iptables服务需要自己用yum install iptabes-se ...
- mac 隐藏文件显示
显示:defaults write com.apple.finder AppleShowAllFiles -bool true隐藏:defaults write com.apple.finder Ap ...
- PHP 防xss攻击
PHP直接输出html的,可以采用以下的方法进行过滤: 1.htmlspecialchars函数 2.htmlentities函数 3.HTMLPurifier.auto.php插件 4.Remove ...
- F - Truck History
F - Truck History #include<cstdio> #include<cstring> #include<iostream> #include&l ...
- USACO 1.2 Transformations (模拟)
模拟题目,依照题目给定的要求变换图形就可以,变换的优先级依次减小. 这个题目我写的非常乱.只是最还还是勉强能够执行 /* ID:twd30651 PROG:transform LANG:C++ */ ...
- Ural 1152 False Mirrors(状压DP)
题目地址:space=1&num=1152">Ural 1152 初学状压DP,原来状压仅仅是用到了个位运算.. 非常水的状压DP.注意四则运算的优先级是高于位运算的..也就是 ...
- CodeFirst模式,容易引发数据迁移问题(不建议使用)
code first 模式 .模型类需要数据契约绑定[DataContract] .模型参数需要[DataMember]-----(可以序列化) .(同上)也可以在类的上面增加[Table(" ...