Python Forum
django - reset password template - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: django - reset password template (/thread-35883.html)



django - reset password template - rwahdan - Dec-26-2021

Hi,

I have the following code but for some reason on the paths don't work from the urls file!

from django.urls import path
from . import views
from .views import UserEditView, PasswordsChangeView
from django.contrib.auth import views as auth_views

urlpatterns = [

  path('login_user/', views.login_user, name="login"),
  path('logout_user/', views.logout_user, name="logout"),
  path('register_user/', views.register_user, name="register_user"),
  path('edit_profile/', UserEditView.as_view(), name="edit_profile"),
  path('password/', PasswordsChangeView.as_view(template_name='authenticate/change-password.html')),




  path('reset_password/', 
    auth_views.PasswordResetView.as_view(template_name='authenticate/password_reset.html'), 
    name="reset_password"),

  path('reset_password_sent/', 
    auth_views.PasswordResetDoneView.as_view(template_name='authenticate/password_reset_sent.html'), 
    name="password_reset_done" ),
  
  path('reset/<uidb64>/<token>/', 
    auth_views.PasswordResetConfirmView.as_view(template_name='authenticate/password_reset_form.html'), 
    name="password_reset_confirm"),  
  
  path('reset_password_complete/', 
    auth_views.PasswordResetCompleteView.as_view(template_name='authenticate/password_reset_done.html'),
    name="password_reset_complete"),

]
the below is not loading the template file:
  path('reset/<uidb64>/<token>/', 
    auth_views.PasswordResetConfirmView.as_view(template_name='authenticate/password_reset_form.html'), 
    name="password_reset_confirm"),  
instead it is bringing the one that is used by django as attached.


RE: django - reset password template - rwahdan - Dec-26-2021

I found the solution but can someone explain please:

path('reset/<uidb64>/<token>/', 
    auth_views.PasswordResetConfirmView.as_view(template_name='EmailRegs/password_reset_confirm.html'), 
    name="password_reset_confirm"),
I took off the part at the beginning of the path:
path('<uidb64>/<token>/', 
    auth_views.PasswordResetConfirmView.as_view(template_name='EmailRegs/password_reset_confirm.html'), 
    name="password_reset_confirm"),
then it works.


RE: django - reset password template - Jeff900 - Dec-26-2021

Could be because you are using relative paths somewhere in your code?