7

I'm trying to use the password reset setup that comes with Django, but the documentation is not very good for it. I'm using Django 1.0 and I keep getting this error:

Caught an exception while rendering: Reverse for 'mysite.django.contrib.auth.views.password_reset_confirm' with arguments '()' and keyword arguments ...

in my urlconf I have something like this:

#django.contrib.auth.views
urlpatterns = patterns('django.contrib.auth.views',    
    (r'^password_reset/$', 'password_reset', {'template_name': 'accounts/registration/password_reset_form.html', 'email_template_name':'accounts/registration/password_reset_email.html', 'post_reset_redirect':'accounts/login/'}),
    (r'^password_reset/done/$', 'password_reset_done', {'template_name': 'accounts/registration/password_reset_done.html'}),
    (r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'password_reset_confirm', {'template_name': 'accounts/registration/password_reset_confirm.html', 'post_reset_redirect':'accounts/login/', 'post_reset_redirect':'accounts/reset/done/'}),
    (r'^reset/done/$', 'password_reset_complete', {'template_name': 'accounts/registration/password_reset_complete.html'}),
)

The problem seems to be in this file:

password_reset_email.html 

on line 7

{% url django.contrib.auth.views.password_reset_confirm uidb36=uid, token=token %}

I'm at loss as to what's going on, so any help would be appreciated.

Thanks

4 Answers 4

3

Edit: I used your example, and had to change to not use keyword parameters.

{% url django.contrib.auth.views.password_reset_confirm uid, token %}

Named parameters do work, as long as both uid and token are defined. If either are not defined or blank I get the same error you do:

{% url django.contrib.auth.views.password_reset_confirm uidb36=uid, token=token %}
Sign up to request clarification or add additional context in comments.

2 Comments

Can you explain this a little more. What do you mean by "Try adding a line for password_reset_confirm in urls.py". The third URL in my above example is for password_reset_confirm. How else should I be adding it to my urls.py file? Thanks
My mistake in overlooking that, I edited what worked for me above.
2

Just wanted to post the solution I came up with. The problem was in this line:

{% url django.contrib.auth.views.password_reset_confirm uidb36=uid, token=token %}

I'm not really a 100% why either, so I just hard coded the url like this:

http://mysite.com/accounts/reset/{{uid}}-{{token}}/

Comments

2

I've struggled with this for over an hour trying everything on this page and every other page on the internet. Finally to solve the problem in my case i had to delete

{% load url from future %}

from the top of my password_reset_email.html template.

Also note, "uidb36=uid" in the url script. Here's my full password_reset_email.html template, I hope it saves someone some time:

{% autoescape off %}
    You're receiving this e-mail because you requested a password reset for your user account at {{ site_name }}.


Please go to the following page and choose a new password:
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url django.contrib.auth.views.password_reset_confirm uidb36=uid token=token %}
{% endblock %}

Your username, in case you've forgotten:" %} {{ user.username }}

Thanks for using our site!

The {{ site_name }} team

{% endautoescape %}

Comments

0

This is a problem I figured out myself not 10 minutes ago. The solution is to add the post_change_redirect value to the dictionary of arguments you are passing to the password_reset view.

So this is what mine now look like:

(r'^/password/$', password_change, {'template_name': 'testing/password.html', 'post_change_redirect': '/account/'})

I hope that does it for you! I agree that the documentation for this particular feature is lacking somewhat, but this solved the exact same issue for my project.

Edit: I really should have scrolled across - you've included that already. Apologies for that, but I hope you get it sorted :)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.