【发布时间】:2015-12-14 16:20:21
【问题描述】:
我正在制作一个 API 资源,我想为此使用 django-rest-swagger,并且我已经完成了 django-rest-swagger documentation 中提供的所有步骤
在我尝试了 url http://localhost:8000/docs/ 之后,我无法打开和查看我的 API。错误截图附在下面。如果有人遇到过,请帮帮我。
【问题讨论】:
-
如果尝试直接访问 /api/ 会发生什么?那里有 500 错误吗?
-
在他的浏览器中打开开发工具,看看你从网络服务器得到什么响应。很可能你会因为 ajax 调用 swagger 获得几个 500。你能发布这些回溯吗?
-
你好 @JoeyWilhelm 当我尝试
http://127.0.0.1:8000/docs/api-docs/时,我收到了这个回复{"info":{"description":"","license":"","title":"","contact":"","termsOfServiceUrl":"","licenseUrl":""},"basePath":"http://127.0.0.1:8000/docs/api-docs","swaggerVersion":"1.2","apiVersion":"","apis":[{"path":"/api"},{"path":"/api-token-auth"},{"path":"/api-token-refresh"},{"path":"/api-token-verify"}]} -
但是如果你试试
http://127.0.0.1:8000/api/呢?很可能是该端点的错误导致 Swagger 出错。 -
您好@miki725 感谢您的建议,我发现错误是由于我要求数据库中的一些旧字段,我已将“mobile_number”字段更改为“phone_number”,因此大摇大摆给我这个错误。