python - 必须安装 coreapi 才能使用 'get_schema_fields()'

标签 python django django-rest-framework core-api

所以我安装了 django-rest-swagger,如 django rest documentation 所示.

继续

from django.conf.urls import url
from rest_framework_swagger.views import get_swagger_view

schema_view = get_swagger_view(title='Pastebin API')

urlpatterns = [
    url(r'^$', schema_view)
]

我不断收到以下错误,

File ".../local/lib/python2.7/site-packages/django_filters/rest_framework/backends.py", line 97, in get_schema_fields assert compat.coreapi is not None, 'coreapi must be installed to use get_schema_fields()' AssertionError: coreapi must be installed to use get_schema_fields()

我安装了以下软件包:

  • 核心接口(interface)==2.0.8
  • Django==1.9.6
  • django-filter==0.15.3
  • django-rest-swagger==2.0.7
  • djangorestframework==3.5.0

编辑:

已安装的应用:

  • 'rest_framework',
  • 'rest_framework_swagger', ...

最佳答案

尝试安装 coreapi,这对我有用

pip install coreapi pyyaml

关于python - 必须安装 coreapi 才能使用 'get_schema_fields()',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40168762/

相关文章:

python - 崩溃后重新连接到套接字

Django - 测试适用于 ajax 请求的 View

python - 如何通过 python 在 openCV 3 中使用 STAR 检测器?

python - 如何解决为用户指定未知字段(Id_card_number)的问题?

django - 过滤 django 中两个模型字段的串联

Django Rest Framework 删除 csrf

python - 如何在非通用 View / View 集中使用分页?

python - 在 Django Rest Framework GET 调用中自定义 JSON 输出

python - 尝试对列表进行平均,但我不知道错误 : unsupported operand type(s) for +: 'int' and 'tuple' 是什么意思

Django CharField 不默认为空字符串