官網(wǎng)本身也有關(guān)于文檔的配置
http://www.django-rest-framework.org/topics/documenting-your-api/
這里我就寫文檔配置 以及功能的簡(jiǎn)單記述
配置url
rom rest_framework.documentation import include_docs_urls
urlpatterns = [
...
url(r'^docs/', include_docs_urls(title='My API title')) #title 顯示文檔名字 可自行修改
]
給list create delete 等功能 加上描述
class UserList(generics.ListAPIView):
"""
get:
get 方法的描述
post:
create 方法的描述
"""
同樣 有一些 參數(shù) 也需要 描述 例如 /goods/{id}
同樣 要告訴 前端 這個(gè)id 是什么
可以在 model serializer filters 中 加上 help_text 就可以了
mobile = serializers.CharField(max_length=11,help_text='手機(jī)號(hào)')
同樣它還支持 base session token 三種方式的登錄 可自行選擇
authentication.PNG
他還有 shell javaScript python 三種接口 調(diào)試
source Code.PNG
把 docs 和 apiRoot 結(jié)合 一起使用 非常方便