解决Django: [TypeError: __init__() missing 1 required positional argument: 'on_delete']
2018-11-11 15:44
671 查看
版权声明:转载请声明出处! https://blog.csdn.net/qq_43125439/article/details/83959115
试用python3.7 + Django2.1.3的时候, 在创建模型类关联外键时, 报如下错误:
Traceback (most recent call last): xxxxxxxxxxx TypeError: __init__() missing 1 required positional argument: 'on_delete'
解决办法:
# 关联外键时设置`on_delete=`参数即可 student_grade = models.ForeignKey('Grades', on_delete=models.CASCADE)阅读更多
相关文章推荐
- django报错TypeError: __init__() missing 1 required positional argument: 'on_delete'
- 调用models.ForeignKey时报“TypeError: __init__() missing 1 required positional argument: 'on_delete'”
- 【python3】 django2.0 在生成数据库表时报错: TypeError: __init__() missing 1 required positional argument: 'on_delete'
- django models层外键报错TypeError: __init__() missing 1 required positional argument: 'on_delete'
- Django在根据models生成数据库表时报 __init__() missing 1 required positional argument: 'on_delete'
- Django报错:__init__() missing 1 required positional argument: 'on_delete'
- 记录django的错误之:__init__() missing 1 required positional argument: 'on_delete'
- Django在根据models生成数据库表时报 __init__() missing 1 required positional argument: 'on_delete'
- djangoORM添加外建出错问题 __init__() missing 1 required positional argument: 'on_delete'
- 执行python manage.py makemigrations时报错:__init__() missing 1 required positional argument: 'on_delete'
- python3.5安装pyHook,解决【TypeError: MouseSwitch() missing 8 required positional arguments: 'msg', 'x', 'y', 'data', 'time', 'hwnd', and 'window_name'】这个错误!
- __init__() missing 1 required positional argument: 'on_delete'
- TypeError: __init__() missing 1 required positional argument: 'on_delete'
- Django在根据models生成数据库表时报 __init__() missing 1 required positional argument: 'on_delete'
- CodeSign error: code signing is required for product type Application in SDK iOS解决办法
- "Syntax error on tokens, delete these tokens"的分析以及的解决之道
- eclipse 中 Syntax error on token "Invalid Character", delete this token 的解决
- VS2012 error : Required file tracker.exe is missing 解决办法
- 运行代码,出现TypeError: fit() missing 1 required positional argument: 'y',对其进行修改