Ajay
Ajay

Reputation: 41

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

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

Upvotes: 0

Views: 273

Answers (3)

Zebby
Zebby

Reputation: 11

  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

Upvotes: 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.

Upvotes: 2

Tejas nayak
Tejas nayak

Reputation: 54

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

Upvotes: 0

Related Questions