Django使用swagger,访问/docs/出现Expected a `coreapi.Document` instance报错

Internal Server Error: /api-auth/docs/
Traceback (most recent call last):
  File "E:\tools\conda\envs\fastclaim\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "E:\tools\conda\envs\fastclaim\lib\site-packages\django\core\handlers\base.py", line 145, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "E:\tools\conda\envs\fastclaim\lib\site-packages\django\core\handlers\base.py", line 143, in _get_response
    response = response.render()
  File "E:\tools\conda\envs\fastclaim\lib\site-packages\django\template\response.py", line 106, in render
    self.content = self.rendered_content
  File "E:\tools\conda\envs\fastclaim\lib\site-packages\rest_framework\response.py", line 70, in rendered_content
    ret = renderer.render(self.data, accepted_media_type, context)
  File "E:\tools\conda\envs\fastclaim\lib\site-packages\rest_framework_swagger\renderers.py", line 54, in render
    self.set_context(data, renderer_context)
  File "E:\tools\conda\envs\fastclaim\lib\site-packages\rest_framework_swagger\renderers.py", line 70, in set_context
    renderer_context=renderer_context
  File "E:\tools\conda\envs\fastclaim\lib\site-packages\rest_framework_swagger\renderers.py", line 34, in render
    return OpenAPICodec().encode(data, **options)
  File "E:\tools\conda\envs\fastclaim\lib\site-packages\rest_framework_swagger\renderers.py", line 16, in encode
    raise TypeError('Expected a `coreapi.Document` instance')
TypeError: Expected a `coreapi.Document` instance

解决方法:
将djangorestframework 3.11.0回退到djangorestframework 3.9.2解决问题!

你可能感兴趣的:(Django使用swagger,访问/docs/出现Expected a `coreapi.Document` instance报错)