在 Django rest auth 中删除用户端点
Remove user endpoints in Django rest auth
我正在使用 Django rest auth 处理用户帐户。为了更新用户信息,我创建了自定义端点,所以我不需要 djnago-rest-auth 生成的端点 /rest-auth/user/ (GET, PUT, PATCH)
。我如何删除这些端点?
urls.py
urlpatterns = [
path('', include("rest_auth.urls"), name="user-auth"),
path('register', include('rest_auth.registration.urls'), name="user-auth-registration"),
path('<uid>/', views.UserProfileView.as_view(), name="user-profile"),
]
编辑
我想使用 rest-auth 的所有其他 url,如登录、注册等。但我只是不想 /rest-auth/user/
所描述的 here。
未经测试,但这应该有效。
urlpatterns = [
path('user/', django.views.defaults.page_not_found),
path('', include("rest_auth.urls"), name="user-auth"),
path('register', include('rest_auth.registration.urls'), name="user-auth-registration"),
path('<uid>/', views.UserProfileView.as_view(), name="user-profile"),
]
如果没有,您可以在 url 模式中手动定义所有 rest_auth.urls
@bodoubleu 的回答没有用,所以我手动添加了它们。
from rest_auth.views import (
LoginView, LogoutView, PasswordChangeView,
PasswordResetView, PasswordResetConfirmView
)
urlpatterns = [
path('register', include('rest_auth.registration.urls'), name="user-auth-registration"),
path('login', LoginView.as_view(), name="user-login"),
path('logout', LogoutView.as_view(), name='user-logout'),
path('password/change/', PasswordChangeView.as_view(), name='rest_password_change'),
path('password/reset', PasswordResetView.as_view(), name='rest_password_reset'),
path('password/reset/confirm/', PasswordResetConfirmView.as_view(), name='rest_password_reset_confirm'),
path('<uid>/', views.UserProfileView.as_view(), name="user-profile"),
]
我正在使用 Django rest auth 处理用户帐户。为了更新用户信息,我创建了自定义端点,所以我不需要 djnago-rest-auth 生成的端点 /rest-auth/user/ (GET, PUT, PATCH)
。我如何删除这些端点?
urls.py
urlpatterns = [
path('', include("rest_auth.urls"), name="user-auth"),
path('register', include('rest_auth.registration.urls'), name="user-auth-registration"),
path('<uid>/', views.UserProfileView.as_view(), name="user-profile"),
]
编辑
我想使用 rest-auth 的所有其他 url,如登录、注册等。但我只是不想 /rest-auth/user/
所描述的 here。
未经测试,但这应该有效。
urlpatterns = [
path('user/', django.views.defaults.page_not_found),
path('', include("rest_auth.urls"), name="user-auth"),
path('register', include('rest_auth.registration.urls'), name="user-auth-registration"),
path('<uid>/', views.UserProfileView.as_view(), name="user-profile"),
]
如果没有,您可以在 url 模式中手动定义所有 rest_auth.urls
@bodoubleu 的回答没有用,所以我手动添加了它们。
from rest_auth.views import (
LoginView, LogoutView, PasswordChangeView,
PasswordResetView, PasswordResetConfirmView
)
urlpatterns = [
path('register', include('rest_auth.registration.urls'), name="user-auth-registration"),
path('login', LoginView.as_view(), name="user-login"),
path('logout', LogoutView.as_view(), name='user-logout'),
path('password/change/', PasswordChangeView.as_view(), name='rest_password_change'),
path('password/reset', PasswordResetView.as_view(), name='rest_password_reset'),
path('password/reset/confirm/', PasswordResetConfirmView.as_view(), name='rest_password_reset_confirm'),
path('<uid>/', views.UserProfileView.as_view(), name="user-profile"),
]