1
votes

I am using Django rest auth for user account handling. For updating user info i have created custom endpoints, So i don't need the djnago-rest-auth generated endpoints /rest-auth/user/ (GET, PUT, PATCH). How can i remove these endpoints?

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"),
]

Edit

I want to use all other urls of rest-auth like login, register, etc. But i just dont want the /rest-auth/user/ as described here.

2
Provide your urls.py - Sardorbek Imomaliev
@SardorbekImomaliev added - Nithin

2 Answers

3
votes

@bodoubleu 's answer didn't work, So i added them manually.

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"),
]
0
votes

Untested but this should work.

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"),
]

If not you can manually define all the rest_auth.urls in your url patterns