在rest_framework.documentation的自动生成视图中,当我进行帖子测试时,没有字段来填充我的参数,以及如何添加请求参数的描述,例如"删除>列表&的api #34;
我无法从文档中获得这些想法:Documenting your API
我应该在这里写一些代码吗?
@api_view(['POST'])
def Login(request):
try:
username=request.data['username']
password=request.data['password']
except Exception as error:
return Response(str(error), status=status.HTTP_400_BAD_REQUEST)
user = authenticate(username=username, password=password)
if user is None:
或:
from django.conf.urls import url, include
from django.contrib import admin
from . import views
from rest_framework.documentation import include_docs_urls
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^media/(?P<file_path>.*)', views.GetMediaFiles),
url(r'^api/',include('api.urls')),
url(r'^docs/', include_docs_urls(title='CLTools API Docs')),
]
谢谢!