从djangorestframework获取异常

时间:2019-01-03 18:13:14

标签: django python-3.x django-rest-framework

我从djangorestframework的JSONEncoder类中收到以下异常:

Traceback:

File "/home/ubuntu/Envs/env_md/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/home/ubuntu/Envs/env_md/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  156.                 response = self.process_exception_by_middleware(e, request)

File "/home/ubuntu/Envs/env_md/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  154.                 response = response.render()

File "/home/ubuntu/Envs/env_md/lib/python3.6/site-packages/django/template/response.py" in render
  106.             self.content = self.rendered_content

File "/home/ubuntu/Envs/env_md/lib/python3.6/site-packages/rest_framework/response.py" in rendered_content
  72.         ret = renderer.render(self.data, accepted_media_type, context)

File "/home/ubuntu/Envs/env_md/lib/python3.6/site-packages/rest_framework/renderers.py" in render
  106.             allow_nan=not self.strict, separators=separators

File "/home/ubuntu/Envs/env_md/lib/python3.6/site-packages/rest_framework/utils/json.py" in dumps
  28.     return json.dumps(*args, **kwargs)

File "/usr/lib/python3.6/json/__init__.py" in dumps
  238.         **kw).encode(obj)

File "/usr/lib/python3.6/json/encoder.py" in encode
  199.         chunks = self.iterencode(o, _one_shot=True)

File "/usr/lib/python3.6/json/encoder.py" in iterencode
  257.         return _iterencode(o, 0)

File "/home/ubuntu/Envs/env_md/lib/python3.6/site-packages/rest_framework/utils/encoders.py" in default
  56.         elif (coreapi is not None) and isinstance(obj, (coreapi.Document, coreapi.Error)):

Exception Type: AttributeError at /v0/ui/website/subject-assignment/
Exception Value: module 'coreapi' has no attribute 'Document'

因此,基本上,这就是说我的应用程序(coreapi)没有Document属性。所有其他api都可以正常工作,但是在一个特定的api中却出现此错误。我也找不到与该API有任何不同的地方。 djangorestframework有什么问题吗?或者我应该怎么做调试?

注意:我使用的是django 2.1.4,djangorestframework == 3.9.0,而python版本是3.6.5。

0 个答案:

没有答案