Django does not redirect to correct path on password reset

in django password reset, while the path name is password-reset/done/, django redirects me to password_reset/done/ page. No redirects work except password-reset/ also password-reset-confirm not working to. Return /user/reset/done/.

user/password-reset/ is working : enter image description here

When POST the form return default django page and the link like this : enter image description here

Return link should be 'password-reset/done/' but return link is : 'password_reset/done/'

My user app urls.py

from django.contrib import admin
from django.urls import path
from . import views
from django.conf.urls.static import static
from django.conf import settings
from django.contrib.auth import views as auth_views

app_name = "user"


urlpatterns = [
path('register/',views.register,name="register"),
path('login/',views.loginUser,name="login"),
path('logout/',views.logoutUser,name="logout"),
path('profile/',views.profileUser,name="profile"),
path('password-reset/',auth_views.PasswordResetView.as_view(template_name="password_reset.html"), name="password_reset"),
path('password-reset/done/',auth_views.PasswordResetDoneView.as_view(template_name="password_reset_done.html") , name="password_reset_done"),
path('password-reset-confirm/<uidb64>/<token>/',auth_views.PasswordResetConfirmView.as_view(template_name="password_reset_confirm.html"), name="password_reset_confirm"),
path('password-reset-complete/',auth_views.PasswordResetCompleteView.as_view(template_name="password_reset_complete.html"), name="password_reset_complete"),

] 

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

My Root project urls.py

from django.contrib import admin
from django.urls import path
from django.urls.conf import include
from django.conf import settings
from django.conf.urls.static import static
from django.contrib.auth import views


from article import views

urlpatterns = [
path('admin/', admin.site.urls),
path('',views.index, name="index"),
path('about/',views.about, name="about"),
path('articles/',include("article.urls")),
path('user/',include("user.urls")),
path('user/', include('django.contrib.auth.urls')),
path('contact/',views.contact, name="contact"),

]

urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

You have 2x the path "user/" in your urlpatterns. Just remove one of the paths depending on which urlpatterns you like to have. You do not need to define the users/urls yourself as you follow almost 100% the built-in auth systematic wirh the small difference of the "_". So I would just remove your users/urls.py.

See "Authentication Views" in https://docs.djangoproject.com/en/3.2/topics/auth/default/

Back to Top