原因

执行命令

python manage.py makemigrations

报错

TypeError: __init__() missing 1 required positional argument: 'on_delete'

定义外键报错

解决办法

字段名称 = models.ForeignKey('表名', on_delete=models.CASCADE)
on_delete=models.CASCADE 在 django2.0之前有默认值,之后版本就需要显式指定

Django :执行 python manage.py makemigrations 时报错 TypeError: __init__() missing 1 required positional argument: 'on_delete'的更多相关文章

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

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

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

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

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

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

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

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

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

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

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

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

  7. python进行数据库迁移的时候显示(TypeError: __init__() missing 1 required positional argument: 'on_delete')

    进行数据库迁移的时候,显示  TypeError: __init__() missing 1 required positional argument: 'on_delete' 图示: 出现原因: 在 ...

  8. 【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 ...

  9. django 执行 python manage.py makemigrations 报错

    RuntimeError: Model class app_anme.models.xxx doesn't declare an explicit app_label and isn't in an ...

随机推荐

  1. 大于2T的硬盘怎么分区

    使用parted工具: #yum install parted #parted /dev/sdb    //选择要分的硬盘 GNUParted 2.3Using /dev/sdbWelcome to ...

  2. 使用国内镜像给ROS安装提速

    大半年没写博客了.最近有幸参与机器人导航研究,在学习ROS相关知识.在安装ROS时使用国外的官方源安装非常慢.这里把使用国内镜像的安装方式做一个记录. 笔者用的是Kinetic版本,操作系统是Ubun ...

  3. elasticsearch 常用查询 + 删除索引 + 集群状态诊断

    1.多条件查询 curl -X POST \ http://10.0.0.42:9200/addressbook_user/_search \ -H 'cache-control: no-cache' ...

  4. 【转帖】Linux和GNU系统

    Linux和GNU系统 Richard Stallman 著 http://www.gnu.org/gnu/linux-and-gnu.zh-cn.html 更多信息,请同时参看GNU/Linux常见 ...

  5. Java判断指定日期是否为工作日

    Java判断指定日期是否为工作日 转自:https://www.jianshu.com/p/966659492f2f 转:https://www.jianshu.com/p/05ccb5783f65转 ...

  6. C++str.Format

    C++应该没有这个函数,说的是Format是在MFC程序里看见的 Format是CString字符串类的成员函数CString::Format( LPCTSTR lpszFormat, ... ); ...

  7. php 正则替换特殊字符 和检测是否是中文

    如果是只想输入中文的话,就这么写,要注意是分gb2312和utf-8的哦: gb2312:if(!preg_match("/^[".chr(0xa1)."-". ...

  8. Excel导入异常Cannot get a text value from a numeric cell解决

    POI操作Excel时偶尔会出现Cannot get a text value from a numeric cell的异常错误. 异常原因:Excel数据Cell有不同的类型,当我们试图从一个数字类 ...

  9. java线程的方便调用方式

    一直用java的线程,总感觉写起来阅读或书写起来不是方便,改进之. 实现类: public class Task<R> { private ExecutorService executor ...

  10. Fox新闻报道,帮助北朝鲜使用加密货币专家被捕

    根据司法部的刑事诉讼,一名美国加密货币专家周四在洛杉矶被捕,原因是涉嫌帮助朝鲜使用加密货币逃避美国的制裁.网民都说敢帮助敌人,就应该关起来.  ​​​