在 admin 中检查类 CustomUserAdmin 错误的字段/字段集/排除属性

问题描述

即使我已经删除并再次迁移,我仍然收到此错误。最初,我在抽象用户模型后添加了额外的布尔字段 is_vehicle_owner,然后它被删除了。但我收到这个错误。 任何帮助将不胜感激。

FieldError at /admin/accounts/customuser/1/change/
UnkNown field(s) (is_vehicle_owner) specified for CustomUser. Check 
fields/fieldsets/exclude attributes of class CustomUserAdmin.
Request Method: GET
Request URL:    http://127.0.0.1:8000/admin/accounts/customuser/1/change/
Django Version: 3.1.4
Exception Type: FieldError
Exception Value:    
UnkNown field(s) (is_vehicle_owner) specified for CustomUser. Check 
fields/fieldsets/exclude attributes of class CustomUserAdmin.
Exception Location:  
C:\Users\DELL\AppData\Local\Programs\Python\python39\lib\site- 
packages\django\contrib\admin\options.py,line 711,in get_form
Python Executable:   
C:\Users\DELL\AppData\Local\Programs\Python\python39\python.exe
Python Version: 3.9.0
Python Path:    
['E:\\Django\\projects\\carpool','C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\python39\\python39.zip','C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\python39\\DLLs','C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\python39\\lib','C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\python39','C:\\Users\\DELL\\AppData\\Local\\Programs\\Python\\python39\\lib\\site- 
packages']
Server time:    Thu,18 Mar 2021 18:28:58 +0000
Traceback Switch to copy-and-paste view
C:\Users\DELL\AppData\Local\Programs\Python\python39\lib\site- 
packages\django\contrib\admin\options.py,line 709,in get_form
        return modelform_factory(self.model,**defaults) …
▶ Local vars
C:\Users\DELL\AppData\Local\Programs\Python\python39\lib\site- 
packages\django\forms\models.py,line 555,in modelform_factory
return type(form)(class_name,(form,),form_class_attrs) …
▶ Local vars
C:\Users\DELL\AppData\Local\Programs\Python\python39\lib\site- 
packages\django\forms\models.py,line 268,in __new__
            raise FieldError(message) …
▶ Local vars
During handling of the above exception (UnkNown field(s) (is_vehicle_owner) 
 specified for CustomUser),another exception occurred:
 C:\Users\DELL\AppData\Local\Programs\Python\python39\lib\site- 
packages\django\core\handlers\exception.py,line 47,in inner
            response = get_response(request) …

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)