1.REST framework 可以自动帮助我们生成接口文档. 接口文档以网页的方式呈现.
自动接口文档能生成的是继承自 APIView 及其子类的视图.
REST framewrok 生成接口文档需要 coreapi 库的支持. pip install coreapi
2. 使用方法
- from rest_framework.documentation import include_docs_urls
- urlpatterns = [
- ...
- # 生成 DRF 文档的配置
- url(r'^docs/', include_docs_urls(title="慕学生鲜")),
- ...
- ]
3. 浏览器访问, 此时肯定会报错, 'AutoSchema' object has no attribute 'get_link', 原因如下, 即从 3.10 开始 REST 就把 AutoSchema 从 coreapi 迁移到了 OpenAPI 里,
转载自 https://www.cnblogs.com/knighterrant/p/10597651.html
--- 君子处其实, 不处其华; 治其内, 不治其外 张居正 ----
来源: http://www.bubuko.com/infodetail-3357199.html