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

图示:

出现原因:

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

修改:

python进行数据库迁移的时候显示(TypeError: __init__() missing 1 required positional argument: 'on_delete')的更多相关文章

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

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

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

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

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

  4. 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 ...

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

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

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

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

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

    报错的原因呢,就是在设计model时我弄了个外键,然后就报错了... 不难看出,它是想让我们在表与表关联时添加一个on_delete参数 解决办法: 如其所愿,加上on_delete=models.C ...

  8. 解决TypeError: __init__() missing 1 required positional argument: 'on_delete'

    试用Djiango的时候发现执行mange.py makemigrations 和 migrate是会报错,少位置参数on_delete,查了一下是因为指定外键的方式不对,改一下就OK了. 代码如下: ...

  9. 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 ...

随机推荐

  1. 关于position的操作

    1.position:relative 相较于正常位置的定位 <!DOCTYPE html> <html lang="en"> <head> & ...

  2. C#/Java 调用WSDL接口及方法

    一.C#利用vs里面自带的“添加web引用”功能: 1.首先需要清楚WSDL的引用地址  如:http://www.webxml.com.cn/Webservices/WeatherWebServic ...

  3. 50. Pow(x, n) (JAVA)

    Implement pow(x, n), which calculates x raised to the power n(xn). Example 1: Input: 2.00000, 10 Out ...

  4. 43. Multiply Strings (JAVA)

    Given two non-negative integers num1 and num2represented as strings, return the product of num1 and  ...

  5. tomcat 启动日志乱码,idea中运行Tomcat也出现中文乱码:“淇℃伅”

    打开到tomcat安装目录下的conf/文件夹 修改logging.properties文件, 找到 java.util.logging.ConsoleHandler.encoding = utf-8 ...

  6. 流畅的Python (Fluent Python) —— 第二部分01

    2.1 内置序列类型概览 Python 标准库用 C 实现了丰富的序列类型,列举如下. 容器序列 list. tuple 和 collections.deque 这些序列能存放不同类型的数据. 扁平序 ...

  7. fastadmin 搭建到云虚拟主机

    1.把public下的index.php.router.php.install.php.admin_*******.php..htaccess(伪静态文件),移到  文件夹:/htdocs   根目录 ...

  8. ID 学习二 FILE I/O

    TCP CONNECT 此文件io工具用于打开和另外一台电脑的tcp/ip连接 电脑(本地网络.ip地址或者完整主机名称) Inputs Server ID 想要连接的主机名称或者IP地址 TCP P ...

  9. <转> thinkPHP的常用配置项2

    'URL_PATHINFO_DEPR'=>'-',//修改URL的分隔符'TMPL_L_DELIM'=>'<{', //修改左定界符'TMPL_R_DELIM'=>'}> ...

  10. 36.React基础介绍——2019年12月24日

    2019年12月24日16:47:12 2019年10月25日11:24:29 主要介绍react入门知识. 1.jsx语法介绍 1.1 介绍 jsx语法是一种类似于html标签的语法,它的作用相当于 ...