【问题标题】:coreapi must be installed to use 'get_schema_fields()'必须安装 coreapi 才能使用 'get_schema_fields()'
【发布时间】:2017-03-03 07:11:34
【问题描述】:

所以我安装了 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)
]

我不断收到以下错误,

文件“.../local/lib/python2.7/site-packages/django_filters/rest_framework/backends.py”,第 97 行,在 get_schema_fields assert compat.coreapi 不是 None,'必须安装 coreapi 才能使用get_schema_fields()' AssertionError:必须安装coreapi才能使用get_schema_fields()

我安装了以下软件包:

  • coreapi==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',...

【问题讨论】:

  • 在 settings.py 中显示 INSTALLED_APPS

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


【解决方案1】:

尝试安装 coreapi,这对我有用

pip install coreapi pyyaml

【讨论】:

    【解决方案2】:

    我认为这是一个错误。它可能会在rest framework 3.5.1中修复

    看到这个问题: https://github.com/tomchristie/django-rest-framework/pull/4601#event-831195901

    【讨论】:

    • 确实.. master 上的最新提交已经修复了这个问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-24
    • 1970-01-01
    • 1970-01-01
    • 2019-11-22
    • 1970-01-01
    • 1970-01-01
    • 2021-09-08
    相关资源
    最近更新 更多