Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django 1.0, using default password reset

Tags:

python

django

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

like image 723
Joe Avatar asked Jun 02 '09 22:06

Joe


2 Answers

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 %}
like image 138
dar Avatar answered Sep 23 '22 20:09

dar


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}}/
like image 41
Joe Avatar answered Sep 22 '22 20:09

Joe