1. 程式人生 > >TypeError: super(type, obj): obj must be an instance or subtype of type

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

父類 self 出現問題 error upper err ins 方法 sof

問題:

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

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

出現問題原因:

  在類的繼承時候,super方法繼承時間,BnnerCourseAdmin名字並不是本類名字可能是父類名字,需要把名字改成本類名字

那,如何解決?

  把 BnnerCourseAdmin名字改寫成 定義supper類的本名,而不是父類名字

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