Search code examples
pythondjangodjango-rest-frameworkdjango-rest-auth

How to override a Django url path that is provided by a library?


I'm currently building out an authentication server using Django, djangorestframework, and django-rest-auth. My problem is actually pretty simple I think, but I haven't really been able to find any resources on it.

Here's my issue, in django-rest-auth there is a specific url to change a user's password, which is /rest-auth/password/reset/. I'd like the url to instead be /auth/password/change/, but don't want to edit the library code to do so.

The issue is that as of now, in my url.py file, I have the rest-auth urls imported as such:

from django.urls import path, include

urlpatterns = [
    path('', include('rest_auth.urls')),
]

So it just imports the urls as written in the library. How can I change the specific url to what I want?


Solution

  • You just need to add a url like this

    path('/auth/password/change/', your_view)
    

    your_view will be same as view of /rest-auth/password/reset/ which is PasswordResetView.