AttributeError: 'AutoSchema' object has no attribute 'get_link'异常处理

REST framework可以自动帮助我们生成接口文档。REST framewrok生成接口文档需要coreapi库的支持。在访问生成的接口文档时,可能会发生如下错误:
AttributeError: 'AutoSchema' object has no attribute 'get_link'异常处理_第1张图片
抛出如下异常:
link = view.schema.get_link(path, method, base_url=self.url)
AttributeError: ‘AutoSchema’ object has no attribute ‘get_link’
[01/Aug/2019 02:32:03] “GET /docs/ HTTP/1.1” 500 109358

在配置文件settings.py中重新指定schema_class的配置

REST_FRAMEWORK = {
 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',
    # 新版drf schema_class默认用的是rest_framework.schemas.openapi.AutoSchema

}

你可能感兴趣的:(DRF异常处理)