0

I want to implement password reset functionality on my web page but I am getting NoReverseMatch at /accounts/password_reset/ Reverse for 'password_reset_confirm' not found. 'password_reset_confirm' is not a valid view function or pattern name. error. please help me to solve this error

url.py Code:

app_name="accounts"
urlpatterns=[


path('password_reset/', auth_views.PasswordResetView.as_view(template_name="password_reset.html",success_url=reverse_lazy('accounts:password_reset_done')), name='password_reset'),

  path('password_reset_done/', auth_views.PasswordResetDoneView.as_view(), name='password_reset_done'),

 path('reset/<uidb64>/<token>/',    auth_views.PasswordResetConfirmView.as_view(template_name="password_reset_confirm.html",success_url=reverse_lazy('accounts:password_reset_complete')), 
 name="password_reset_confirm"),

path('reset_password_complete/', 
    auth_views.PasswordResetCompleteView.as_view(template_name="password_reset_done.html"), name="password_reset_complete"),

]

passwrd_reset.html

{% extends 'base.html' %}
{% block title %}Password Reset Page{% endblock %} 
{% load crispy_forms_tags %}
{% block body %}
<div class="container">
<div class="row mt-5 pt-3">
    <div class="col-md-8 offset-md-2">
        <div class="card my-3 shadow">
            <div class="card-body">
<h4>Password Reset Page</h4>
                <hr>
                <div class="alert alert-info">
                    Enter email and a mail will be sent with instructions to reset password
                </div>
                <form method="POST">
                    {% csrf_token %}
                    {{ form|crispy }}
                    <input class="btn btn-primary btn-block" type="submit" value="Reset Password">
 </form>
                <hr>
            </div>
        </div>
    </div>
</div>
{% endblock body%}

Additional info about me apps I have two apps one is dashboard and anther is accounts I want to implement this in my accounts app

Ajay
  • 31
  • 1
  • 6
  • 1
    Please check if this helps: https://stackoverflow.com/questions/66406530/keep-getting-this-error-of-reverse-for-password-reset-confirm-not-found-pass – Ashish Nautiyal May 16 '22 at 04:47
  • 1
    Does this answer your question? [Keep getting this error of Reverse for 'password\_reset\_confirm' not found. 'password\_reset\_confirm' is not a valid view function or pattern name](https://stackoverflow.com/questions/66406530/keep-getting-this-error-of-reverse-for-password-reset-confirm-not-found-pass) – Abdul Aziz Barkat May 16 '22 at 05:35
  • @ Ashish Nautiyal and @ Abdul Aziz Barkat before posting this question I have tried this solution but this answer does not work for me – Ajay May 16 '22 at 06:19
  • I have tried paasword_reset_confirm url like this `path( 'password_reset///', auth_views.PasswordResetConfirmView.as_view( template_name='reset_password_confirm.html', success_url=reverse_lazy('accounts:password_reset_complete') ), name='password_reset_confirm' ),` – Ajay May 16 '22 at 06:54
  • but this is not working for me I still am getting the same error – Ajay May 16 '22 at 06:56
  • I am also getting this with the above error which I have mentioned in my asked question, Is there anything to do in the password_reset.html file `Error during template rendering In template C:\Users\Hp\Desktop\myProjects\yearlyproject\proenv\lib\site-packages\django\contrib\admin\templates\registration\password_reset_email.html, error at line 6` – Ajay May 16 '22 at 06:58

3 Answers3

1

In your core app (where you have settings.py). Go to your urls.py file and paste:

path('', include('django.contrib.auth.urls'))

Note you have to import include from django.urls.

1
  1. Navigate to your main url.py located in the same folder as the settings.py
  2. Import include from django.urls (from django.urls import include)
  3. Add the line below to urlpatterns path('', include('django.contrib.auth.urls')),

Reload the server and retry

Zebby
  • 11
  • 2
0

Check your html file names. Is there a password_reset_confirm.html file?

Tejas nayak
  • 54
  • 2
  • 7