DRF使用文檔功能

DRF自帶的的文檔生成功能,非常方便。

配置:

from rest_framework.documentation import include_docs_urls

urlpatten=[
    ……
    url(r'docs/', include_docs_urls(title="yitao")),
    ……
]

在settings.py文件中,需加上

REST_FRAMEWORK = {
    'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.AutoSchema'
}

進入文檔頁面:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章