django.db.models.fields.related.ForeignObject.__init__() got multiple values for keyword argument 'to_fields'

原因:使用了to_fields

说明:使用外键关联字段时,应该使用to_field,而不是to_fields

错误示例:

worker = models.ForeignKey(verbose_name="负责人",to="UserInfo",to_fields="name",on_delete=models.CASCADE)

正确示例:

worker = models.ForeignKey(verbose_name="负责人",to="UserInfo",to_fields="name",on_delete=models.CASCADE)

got multiple values for keyword argument 'to_fields'的更多相关文章

  1. TypeError: test() got multiple values for keyword argument 'key'

    原因是: 1.函数调用的最终形式只会调用两个函数.一个list参数和一个dict参数,格式为call(func, list, dict); 2.如果传入参数中有key参数,那么首先key参数(包括扩展 ...

  2. python报错 TypeError: a() got multiple values for argument 'name'

    [问题现象] 在一次调用修饰函数中出现了问题,折腾了一下午,一直报错 TypeError:  got multiple values for argument 只是很简单的调用 from tsu2Ru ...

  3. 细说 PEP 468: Preserving Keyword Argument Order

    细说 PEP 468: Preserving Keyword Argument Order Python 3.6.0 版本对字典做了优化,新的字典速度更快,占用内存更少,非常神奇.从网上找了资料来看, ...

  4. senlin __init__() got an unexpected keyword argument 'additional_headers'

    从senlin源码重新编译更新了服务,然后执行 senlin的 cli就遇到了错误: __init__() got an unexpected keyword argument 'additional ...

  5. TypeError: 'encoding' is an invalid keyword argument for this function

    python 2.7 问题 data_file = open("F:\\MyPro\\data.yaml", "r", encoding='utf-8') 运行 ...

  6. TypeError: parse() got an unexpected keyword argument 'transport_encoding'

    错误: TypeError: parse() got an unexpected keyword argument 'transport_encoding'You are using pip vers ...

  7. get() got an unexpected keyword argument

    TypeError: get() got an unexpected keyword argument 'news_id'ERROR basehttp 154 "GET /news/3/ H ...

  8. TypeError: __init__() got an unexpected keyword argument 't_command'

    python  .\manage.py migrate 报错如下 λ python .\manage.py migrateTraceback (most recent call last): File ...

  9. TypeError: while_loop() got an unexpected keyword argument 'maximum_iterations'

    错误: TypeError: while_loop() got an unexpected keyword argument 'maximum_iterations' 参照https://blog.c ...

  10. Django--bug--__init__() got an unexpected keyword argument 'qnique'

    建立模型之后,执行迁移,报如下错误: __init__() got an unexpected keyword argument 'qnique' 错误原因:模型的属性的约束添加错误,这种错误一般就是 ...

随机推荐

  1. 基于Hexo的GitHub Pages个人博客搭建

    1.创建一个个人主页仓库 仓库命名最好为github账户名.github.io,这样可以通过https://github账户名.github.io访问 2.安装Hexo 此处采用局部安装: # npm ...

  2. pat乙级 1020 月饼

    #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> ...

  3. kali-国内源-更新系统

    1.更换国内源 vim /etc/apt/sources.list deb https://mirrors.aliyun.com/kali kali-rolling main non-free con ...

  4. RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

    错误原因:数据有的在cpu上有的在gpu上debug:断点到出错位置查看类型,或者打印`x.is_cuda`查看修改:将cpu上的数据通过`.to(device)`加载到gpu上

  5. npm发包

    1.npm init 2.注册npm,https://www.npmjs.com/ 3.npm需要更新最新的npm 4.npm login 5.npm publish --access=public

  6. iOS 防止charles抓包

    方案一:检查手机Wifi是否设置了代理     public func fetchHttpProxy() -> Bool {        guard let proxy = CFNetwork ...

  7. 每次 git 都需要输入用户名和密码的解决办法

    git config --global credential.helper store git pull /git push (第一次输入,下次就不用再次输入数据)

  8. H5移动端跳转唤起QQ在线客服与跳转支付宝

    以下两段代码都是找了很久的,在某个删库跑路的支付商那里找到的! H5移动端跳转QQ 实现在线客服 <a href="mqqwpa://im/chat?chat_type=wpa& ...

  9. A调用B方法,@Transactional事务问题

    总结:方法A调用方法B:1.如果只有A加@Transactional注解:则AB在同一事务中,任意异常都回滚:2.如果只有B加@Transactional注解:AB方法为同一类,事务失效任意异常都不回 ...

  10. 前端下载的方式总结(url,文件流,压缩包)

    1.比较常见的是通过a标签的href属性直接访问文件url地址. (1)const downloadUrl = (url: string, file_name?: string) => { if ...