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

都是has no field name最后一个class名,然后错误文件都是指向同一个文件\Python\Python36\lib\site-packages\django\db\models\options.py in get_field, line 568。都是这一行。

错误信息:

Environment:



Request Method: GET

Request URL: http://127.0.0.1:8000/xadmin/courses/courseresource/


Django Version: 2.0.1

Python Version: 3.6.4

Installed 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'

http://img4.mukewang.com/5a81949f000111e005000208.jpg

http://img.mukewang.com/5a8194a0000190ed05000286.jpg

http://img4.mukewang.com/5a8194a000016e4a05000328.jpg


SuccessorSocialism
浏览 2014回答 2
2回答

_遥不可及_

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

奔跑的小码农

最后怎么解决的啊
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python