keep getting Reverse for 'password_reset_confirm' not found. 'password_reset_confirm' is not a valid view function or pattern name. error

Issue

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

Solution

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.

Answered By – Caio César P. Ricciuti

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published