-
Notifications
You must be signed in to change notification settings - Fork 10
Swagger Docs Step
冒菜略寡味 edited this page May 9, 2018
·
2 revisions
pipenv install django-rest-swagger==2.2.0
在accountbook/settings.py
文件中添加如下:
INSTALLED_APPS = (
...
'rest_framework_swagger',
)
from django.urls import path
from rest_framework_swagger.views import get_swagger_view
schema_view = get_swagger_view(title='Accountbook API')
urlpatterns = [
path('docs/', schema_view)
]
访问http://127.0.0.1:8000/docs/
查看swagger
文档;
默认不设置,点击登录会调转到错误的登录URL上,故这里复用RDF中的登录登出,
设置accountbook/settings.py
文件,添加如下:
LOGIN_URL = 'rest_framework:login'
LOGOUT_URL = 'rest_framework:logout'
即可正常登录登出,并获得发送请求的权限;
... 累到整夜不能睡,夜色哪裡都是美 ...
昨日擔當 昨日敢想
昨日轉眼 就跌撞
夏時夢長 秋時晝短
清冽途上 不遠望