在使用 Django2.0 版本的 Django Rest Framwork 时,Django DeBug 报错

django-filter: TypeError at *** __init__() got an unexpected keyword argument 'name'

百度无效,于是查阅官方文档。

在 官方文档  中,是这样写的

To alter strictness behavior, the appropriate view code should be overridden. More details will be provided in future docs.

Filter.name renamed to Filter.field_name (#792)

The filter name has been renamed to field_name as a way to disambiguate the filter’s attribute name on its FilterSet class from the field_name used for filtering purposes.

所以我们代码中的 name 要改为 field_name:

    price_min = django_filters.NumberFilter(name='shop_price', lookup_expr='gte')
    price_max = django_filters.NumberFilter(name='shop_price', lookup_expr='lte')
    price_min = django_filters.NumberFilter(field_name='shop_price', lookup_expr='gte')
    price_max = django_filters.NumberFilter(field_name='shop_price', lookup_expr='lte')

再调试一下即可成功

小结:对于部分百度不到的错误,不要害怕看官方文档,官方文档往往是最权威的。

Django2.0——django-filter: TypeError at *** __init__() got an unexpected keyword argument 'name'的更多相关文章

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

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

  2. 关于Jupyter Notebook无法自动补全(Autocompletion),报错TypeError: __init__() got an unexpected keyword argument 'column' 的解决方案

    关于Jupyter Notebook无法自动补全(Autocompletion),报错TypeError: __init__() got an unexpected keyword argument ...

  3. TypeError: __init__() got an unexpected keyword argument 'serialized_options'

    问题描述: TypeError: __init__() got an unexpected keyword argument 'serialized_options' File "objec ...

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

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

  5. django出现__init__() got an unexpected keyword argument 'mimetype‘ 问题解决

    这种问题好多新手按照djangobook学习的时候应该都遇到过,是因为这是老的django的写法,新的django已经升级改变了很多东西. 处理方法如下: I think you are not us ...

  6. Django-filter报错:__init__() got an unexpected keyword argument 'name'

    原因是 自从 django-filter2.0之后 将Filter的name字段 更名为 field_name 所以需要这样写: class GoodsFilter(filters.FilterSet ...

  7. kivy __init__() got an unexpected keyword argument '__no_builder' Kivy

    from kivy.lang.builder import Builder from kivy.app import App, runTouchApp from kivy.uix.boxlayout ...

  8. ypeError: __init__() got an unexpected keyword argument 'shape'

    采用TensorFlow支持通过tf.Graph函数来生成新的向量图,代码如下: import tensorflow as tf g1 = tf.Graph() with g1.as_default( ...

  9. Django TypeError: render() got an unexpected keyword argument 'renderer'

    场景: Xadmin添加plugin 来源: 1. xadmin与DjangoUeditor的安装 (第3.3章节) 2. 增加富文本编辑器Ueditor (第14.7章节) 报错: Django T ...

随机推荐

  1. Dynamics CRM - 解决无法使用 Ribbon Workbench 2016 定制 Sub-Grid View Button 的问题(SubGrid MainTab 消失之谜)

    发现问题: 在 Dynamics CRM 开发中,会经常使用 Ribbon Workbench 工具来定制 Button 或者对已有 Button 进行自定义功能开发,比如隐藏 SubGrid 的 A ...

  2. 全面掌握Nginx配置+快速搭建高可用架构 一 Nginx的访问控制

    语法 示例 allow 127.0.0.1; deny all; 缺点:局限性 如果通过代理就可以绕过访问限制,限制不准确 解决 1. http_x_forwarded_for 2. 结合geo模块作 ...

  3. HTML元素类型和类型的转换

    HTML元素分为:块状元素和内联元素 块元素:(block) 1.默认独占一行 2.没有宽度时,默认撑满一排 3.可以定义元素的宽和高 常见的块状元素有div,ul,li,h1-h6,ol 内联,行内 ...

  4. linux部分环境搭建

    连接数据库: mysql -hrm-uf6b23117l3s5t69zjo.mysql.rds.aliyuncs.com -uwswl -pwswl@2019 显示用户: show databases ...

  5. 黑马oracle_day01:03.oracle的查询

    01.oracle体系结构 02.oracle的基本操作 03.oracle的查询 04.oracle对象 05.oracle编程 黑马oracle_day01:03.oracle的查询 09scot ...

  6. (递归)P1192 台阶问题

    题解: 这其实是变相的斐波那契,观察下列等式: //k=2 : 1 2 3 5 8 13 21 34...... //k=3 : 1 2 4 7 13 24 44 81... //k=4 : 1 2 ...

  7. 一维消消乐(DP)

    一维消消乐是一款非常简单的游戏.有n颗珠子排成一排,每一颗珠子有一个价值w(可能是负数). 游戏是这样,你可以选择如若干对相邻的珠子,让他们同时消去.每一对珠子的消失,都会使得总分数加上两颗珠子相乘的 ...

  8. 无车承运前世今生,5G货运管家期待您的加入

    历时三年的无车承运人试点工作结束,从2020年1月1日起,将执行新的暂行<办法>,在这样一个承前启后的阶段,无车承运人的命运如何?网络货运经营者又是何物? 在新赛道下,将迎来什么样的机遇和 ...

  9. Linxu--导出oracle数据

    配置导出的表:(configure.sh) #!/bin/bash function get_config() { tables=( BLOG WF_PROCESS WF_TASK WF_TASK_A ...

  10. Linux--wget,yum,rpm,apt-get

    参考:http://blog.csdn.net/ziju125521/article/details/52575715 使用wget下载一个 rpm包, 然后用 rpm -ivh  xxx.rpm  ...