Django 1.0 using default password reset

I am trying to use the reset password that comes with Django, but the documentation is not very good for it. I am 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 

in line 7

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

I am losing information about what is happening, so any help would be appreciated.

thanks

+6
python django
source share
4 answers

I just want 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 100% either, so I just encoded the url like this:

 http://mysite.com/accounts/reset/{{uid}}-{{token}}/ 
+2
source share

Change I used your example and I had to change so as not to use keyword parameters.

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

Named parameters work if both uid and token are defined. If they are not defined or empty, I get the same error:

 {% url django.contrib.auth.views.password_reset_confirm uidb36=uid, token=token %} 
+3
source share

I struggled with this for more than an hour, trying everything on this page and on every other page on the Internet. Finally, to solve the problem in my case, I had to remove

 {% load url from future %} 

at the top of my password_reset_email.html template.

Also note: "uidb36 = uid" in the url script. Here is my complete password_reset_email.html template, I hope it saves someone else:

 {% 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 %} 
+2
source share

This is a problem that I found out myself 10 minutes ago. The solution is to add the value of post_change_redirect to the dictionary of arguments that you pass to the password_reset view.

So here is what it looks like now:

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

I hope it does for you! I agree that the documentation for this particular function is somewhat missing, but this solved the same problem for my project.

Edit: I really needed to scroll - you already turned this on. I apologize for this, but I hope you sorted it :)

0
source share

All Articles