In my Django Project, I have the following in my urls.py
:
urlpatterns = [
path('register/', views.register, name='register'), # Registration
path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'), # Login Page
path('logout/', auth_views.LogoutView.as_view(next_page='misc:index'), name='logout'), # Logout Page
path('change_password/', auth_views.PasswordChangeView.as_view(template_name='users/change_password.html', success_url='/'), name='change_password'), # Password Change Page
# Password reset pages; They take a lot of parameters
path('reset_password/', auth_views.PasswordResetView.as_view(
template_name='users/password_reset/password_reset_request.html',
email_template_name='users/password_reset/email_password_reset.html',
subject_template_name='users/password_reset/email_password_reset_subject.txt',
success_url='/reset_password/check_your_email/',
from_email='password-reset@sn.local',
html_email_template_name='users/password_reset/email_password_reset.html'
), name='password_reset_request'),
path('reset_password/check_your_email/', views.password_reset_check_your_email, name='password_reset_check_your_email'),
path('reset_password/<uidb64>/<slug:token>/', auth_views.PasswordResetConfirmView.as_view(
template_name='users/password_reset/password_reset_form.html',
post_reset_login=True,
success_url='/'), name='password_reset_form'),
]
All the urls work fine, except the last one which gives me a no reverse match error.
The url I am trying to use is: http://127.0.0.1:8000/reset_password/bAAAAAA/52s-c48e21c49899996ec19c/
When I try to visit it, it gives me this error:
Reverse for 'password_reset_form' with keyword arguments '{'uidb64': '', 'token': ''}' not found. 1 pattern(s) tried: ['reset_password/(?P<uidb64>[^/]+)/(?P<token>[-a-zA-Z0-9_]+)/$']
Edit:
users/password_reset/password_reset_form.html
{% extends 'base.html' %}
{% block title %}Reset Password{% endblock title %}
{% block content %}
<form action="{% url 'users:password_reset_form' uidb64=uidb64 token=token %}" method="post">
{% csrf_token %}
{{ form.as_p }}
<button name="submit" class="btn btn-primary">Reset Password</button>
</form>
{% endblock content %}
I feel like I am missing something here...
Any help would be grately appreciated
PasswordResetConfirmView doesn't send the values of uidb64
or token
to the template context, which is why they appear blank in that error message.
But you don't need them. The form is just posting back to the same URL that displayed it in the first place. So just do:
<form action="" method="post">