Django:禁用文档身份验证

时间:2019-03-31 12:00:10

标签: authentication django-rest-framework documentation disable

我正在使用rest_framework.documentation。而且我已经在DRF中启用了基于令牌的身份验证。

urls.py

from django.contrib import admin
from django.urls import path, include
from .views import CreateUser
from rest_framework.authtoken import views
from rest_framework.documentation import include_docs_urls

urlpatterns = [
    path('users/', CreateUser.as_view(), name='user_create'),
    path('login/', views.obtain_auth_token, name='login'),
    path('docs/', include_docs_urls(title='Machine Test API's')),
    path('admin/', admin.site.urls),
]

我希望无需登录即可访问文档。现在,当我尝试访问/docs/ api时,它显示:

{
    "detail": "Authentication credentials were not provided."
}

0 个答案:

没有答案