DRF 登录按钮未显示在 BrowsableApi 中

Con*_*Ara 4 django-rest-framework

我遇到了 DRF 登录按钮的问题。尽管登录、注册和注销功能按预期工作正常。但登录/注销按钮未显示。

我正在使用 Knox 进行身份验证。 在此输入图像描述

到目前为止我做了什么

设置.py

INSTALLED_APPS = [
    'rest_framework',
    'knox',
]

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'knox.auth.TokenAuthentication',
        'rest_framework.authentication.SessionAuthentication',
    ),
}
Run Code Online (Sandbox Code Playgroud)

urls.py

urlpatterns = [
    path('api/auth', include('knox.urls')),
    path('api/auth/register', RegisterAPI.as_view()),
    path('api/auth/login', LoginAPI.as_view()),
    path('api/auth/user', UserAPI.as_view()),
    path('api/auth/logout', knox_views.LogoutView.as_view(), name='knox_logout')
]
Run Code Online (Sandbox Code Playgroud)

小智 5

您应该添加 drf url,例如:

path(
    "api-auth/", include("rest_framework.urls")
),  
Run Code Online (Sandbox Code Playgroud)

然后你会看到...