Reputation: 26768
I am trying to implement password reset funcitonality in django and below are my codes
urls.py
urlpatterns = patterns('',
url(r'^signup/$', 'accounts.views.signup', name="signup_email"),
url(r'^user/password/reset/$', 'django.contrib.auth.views.password_reset', {'template_name':'accounts/forgot_password.html',\
'post_reset_redirect' : '/user/password/reset/done/'}, name="reset_password"),
url(r'^user/password/reset/done/$', 'django.contrib.auth.views.password_reset_done'),
forgot_password.html
<form accept-charset="UTF-8" action="{% url 'reset_password' %}" class="reset_pass" id="reset_pass" method="post">
{% csrf_token %}
<div class="control-group">
<label class="control-label" for="user_email" style="font-size: 18px; color: #474747">Email</label>
<div class="controls">
<input class="" id="id_email" name="email" type="text" value="">
</div>
</div>
<div class="control-group">
<div class="controls">
<button type="submit" value="reset_password" class="btn btn-primary">Send me reset password</button>
</div>
</div>
</form>
so when we go to the url user/password/reset/
a forgot_password.html
is displaying, and when i entered the email and submitted the form i am getting the below errors
and
Error during template rendering
In template /home/user/proj/virtualenvironment/apps/pro_utils/accounts/templates/registration/password_reset_email.html, error at line 7
Can any one please let me know why it is complaining NoReversemtach
even though i am using builtin views ?
Upvotes: 3
Views: 5229
Reputation: 199
You can also use the default urls defined in django.contrib.auth.urls
by including
(r'^accounts/', include('django.contrib.auth.urls')),
to your urls.py
.
The password_reset_confirm
pattern require 2 additional parameters for the uidb64
and the token
:
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
'password_reset_confirm',
See also the answer here: What are the default URLs for Django's User Authentication system?
Upvotes: 1
Reputation: 53386
You need to add that url+view in urls.py
as below
url(r'^user/password/reset/confirm/$',
'django.contrib.auth.views.password_reset_confirm'),
It presents a form for entering a new password.
You may also have to add this as well
url(r'^user/password/reset/complete/$',
'django.contrib.auth.views.password_reset_complete'),
Upvotes: 2