TypeError: super(type, obj): obj must be an instance or subtype of type

问题:

  qs = super(BnnerCourseAdmin, self).queryset()

  TypeError: super(type, obj): obj must be an instance or subtype of type

出现问题原因:

  在类的继承时候,super方法继承时间,BnnerCourseAdmin名字并不是本类名字可能是父类名字,需要把名字改成本类名字

那,如何解决?

  把 BnnerCourseAdmin名字改写成 定义supper类的本名,而不是父类名字

时间: 2024-07-28 16:46:22

TypeError: super(type, obj): obj must be an instance or subtype of type的相关文章

TypeError: invalid 'in' operand obj

尝试在程序去访问远程的Web API,它在运行时,出现异常: TypeError: invalid 'in' operand obj 由于从服务器返回的数据是json.当我们需要得到这些数据时,还得需要Parse.因此我们把代码稍微修改一下: $(function () { $.ajax({ type: "GET", url: "http://localhost:9001/api/size", dataType: "json", contentT

【转】python 调用super()初始化报错“TypeError: super() takes at least 1 argument”

一.实验环境 1.Windows7x64_SP1 2.Anaconda2.5.0 + python2.7(anaconda集成,不需单独安装) 二.实验步骤 2.1 在python中有如下代码: class father(): def __init__(self,age): self.age = age; def get_age(self): print(self.age); class son(father): def __init__(self,age): super().__init__(

org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported或其他Content type不支持处理

很久没从头到尾搭框架,今天搭的过程中,springmvc controller方法入参用@RequestBody自动绑定参数时一直提示各种 not supported 排查问题有两个解决路径: 1)使用post协议提交时,请检查Content type类型,如: $.ajax({ type: "POST", contentType: "application/json;charset=UTF-8", url: "/reg", data: JSON

CORE EF The expected type was 'System.String' but the actual value was of type 'System.Guid'.

[小提示]使用.NET Core EF 开发时,当你的数据库实体中添加了"Id"的字段时,会默认做为主键. 在设置数据库字段类型时如果设置了varchar或者char字段的长度为36时(36是微软GUID的长度),并且数据存储的数据正好是Guid字符串时,在使用EF查询数据库时EF会自动把数据类型转为Guid类型,如果你的数据库实体类中对应的字段正好是string类型时会抛出以下异常: An exception occurred while reading a database val

Python内置函数(63)——super

英文文档: super([type[, object-or-type]]) Return a proxy object that delegates method calls to a parent or sibling class of type. This is useful for accessing inherited methods that have been overridden in a class. The search order is same as that used b

Python内置函数(30)——super

英文文档: super([type[, object-or-type]]) Return a proxy object that delegates method calls to a parent or sibling class of type. This is useful for accessing inherited methods that have been overridden in a class. The search order is same as that used b

python学习第十六天 --继承进阶篇

这一章节主要讲解面向对象高级编程->继承进阶篇,包括类多继承介绍和继承经典类和新式类属性的查找顺序不同之处. 多继承 上一章节我们讲到继承,子类继承父类,可以拥有父类的属性和方法,也可以进行扩展.但是有时候会发现,子类需要继承一个类的方法,又要继承另一个类的方法,才能完成要实现的功能.怎么办?python给我们提供了多继承的概念.类似于C++语言,俗称类的多继承. 看个例子: >>> class Animal(object): def __init__(self,name): se

netty Getting Started--reference

reference from:http://docs.jboss.org/netty/3.1/guide/html/start.html 1.1. Before Getting Started 1.2. Writing a Discard Server 1.3. Looking into the Received Data 1.4. Writing an Echo Server 1.5. Writing a Time Server 1.6. Writing a Time Client 1.7.

.netCore 反射 :Could not load file or assembly 系统找不到指定文件

"System.IO.FileNotFoundException:"Could not load file or assembly 'ClassLibrary2, Culture=neutral, PublicKeyToken=null'. 系统找不到指定的文件."" 在 .net 程序开发中我们会经常用到反射,最近在开始慢慢接触 .netCore.Core 反射的语法也是一样的,所以写下来也没有什么问题,但是一运行,就弹出了开头的 异常. 项目结构如下 Class