为了账号安全,请及时绑定邮箱和手机立即绑定

Django框架 在xadmin中绑定之后,每一个models中的最后一个class会报FieldDoesNotExist错误,

Django框架 在xadmin中绑定之后,每一个models中的最后一个class会报FieldDoesNotExist错误,

SuccessorSocialism 2018-02-12 21:21:11
都是has no field name最后一个class名,然后错误文件都是指向同一个文件\Python\Python36\lib\site-packages\django\db\models\options.py in get_field, line 568。都是这一行。错误信息:Environment:Request Method: GETRequest URL: http://127.0.0.1:8000/xadmin/courses/courseresource/Django Version: 2.0.1Python Version: 3.6.4Installed Applications:['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'users', 'courses', 'organization', 'operation', 'xadmin', 'crispy_forms']Installed Middleware:['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']Traceback:File "C:\Users\16174\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\models\options.py" in get_field  566.             return self.fields_map[field_name]During handling of the above exception ('course'), another exception occurred:File "C:\Users\16174\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\exception.py" in inner  35.             response = get_response(request)File "C:\Users\16174\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\base.py" in _get_response  128.                 response = self.process_exception_by_middleware(e, request)File "C:\Users\16174\AppData\Local\Programs\Python\Python36\lib\site-packages\django\core\handlers\base.py" in _get_response  126.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)File "C:\imooc\MxOnline\extra_apps\xadmin\sites.py" in wrapper  300.                 return self.admin_view(view, cacheable)(*args, **kwargs)File "C:\Users\16174\AppData\Local\Programs\Python\Python36\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func  44.         response = view_func(request, *args, **kwargs)File "C:\imooc\MxOnline\extra_apps\xadmin\sites.py" in inner  208.             return view(request, *args, **kwargs)File "C:\imooc\MxOnline\extra_apps\xadmin\views\base.py" in view  282.             return handler(request, *args, **kwargs)File "C:\Users\16174\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\decorators.py" in _wrapper  62.             return bound_func(*args, **kwargs)File "C:\Users\16174\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\decorators.py" in _wrapped_view  142.                     response = view_func(request, *args, **kwargs)File "C:\Users\16174\AppData\Local\Programs\Python\Python36\lib\site-packages\django\utils\decorators.py" in bound_func  58.                 return func.__get__(self, type(self))(*args2, **kwargs2)File "C:\imooc\MxOnline\extra_apps\xadmin\views\base.py" in method  80.             return filter_chain(filters, len(filters) - 1, _inner_method, *args, **kwargs)File "C:\imooc\MxOnline\extra_apps\xadmin\views\base.py" in filter_chain  49.         return func()File "C:\imooc\MxOnline\extra_apps\xadmin\views\base.py" in _inner_method  74.             return func(self, *args, **kwargs)File "C:\imooc\MxOnline\extra_apps\xadmin\views\list.py" in get  402.         response = self.get_result_list()File "C:\imooc\MxOnline\extra_apps\xadmin\views\base.py" in method  80.             return filter_chain(filters, len(filters) - 1, _inner_method, *args, **kwargs)File "C:\imooc\MxOnline\extra_apps\xadmin\views\base.py" in filter_chain  49.         return func()File "C:\imooc\MxOnline\extra_apps\xadmin\views\base.py" in _inner_method  74.             return func(self, *args, **kwargs)File "C:\imooc\MxOnline\extra_apps\xadmin\views\list.py" in get_result_list  201.         return self.make_result_list()File "C:\imooc\MxOnline\extra_apps\xadmin\views\list.py" in make_result_list  173.         self.list_queryset = self.get_list_queryset()File "C:\imooc\MxOnline\extra_apps\xadmin\views\base.py" in method  80.             return filter_chain(filters, len(filters) - 1, _inner_method, *args, **kwargs)File "C:\imooc\MxOnline\extra_apps\xadmin\views\base.py" in filter_chain  63.         return filter_chain(filters, token - 1, _inner_method, *args, **kwargs)File "C:\imooc\MxOnline\extra_apps\xadmin\views\base.py" in filter_chain  49.         return func()File "C:\imooc\MxOnline\extra_apps\xadmin\views\base.py" in _inner_method  62.                 return fm(func if fargs[1] == '__' else func(), *args, **kwargs)File "C:\imooc\MxOnline\extra_apps\xadmin\plugins\filters.py" in get_list_queryset  120.                             self.model, field_path)File "C:\Users\16174\AppData\Local\Programs\Python\Python36\lib\site-packages\django\contrib\admin\utils.py" in get_fields_from_path  490.         fields.append(parent._meta.get_field(piece))File "C:\Users\16174\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\models\options.py" in get_field  568.             raise FieldDoesNotExist("%s has no field named '%s'" % (self.object_name, field_name))Exception Type: FieldDoesNotExist at /xadmin/courses/courseresource/Exception Value: CourseResource has no field named 'course'
查看完整描述

2 回答

已采纳
?
_遥不可及_

TA贡献26条经验 获得超6个赞

看不到代码不好确认,你看看router配置,估计是那里的锅

查看完整回答
反对 回复 2018-02-15
?
奔跑的小码农

TA贡献4条经验 获得超1个赞

最后怎么解决的啊

查看完整回答
反对 回复 2018-03-30
点击展开后面1
  • 2 回答
  • 0 关注
  • 2013 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信