Reputation: 748
I have just updated my django installation to 1.6 from an older version.
My urls.py file contains the following:
url(r'^user/password/$','django.contrib.auth.views.password_change',name='password_change'),
url(r'^user/password/done/$','django.contrib.auth.views.password_change_done',name='password_change_done'),
url(r'^user/password/reset/$', 'django.contrib.auth.views.password_reset', name='password_reset'),
url(r'^user/password/password/reset/done/$', 'django.contrib.auth.views.password_reset_done', name='password_reset_done'),
url(r'^user/password/reset/complete/$', 'django.contrib.auth.views.password_reset_complete', name='password_reset_complete'),
#url(r'^user/password/reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm', name='password_reset_confirm'),
url(r'^user/password/reset/confirm/(?P<uidb36>[0-9A-Za-z_\-]+)/(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm_uidb36', name='password_reset_confirm'),
Been trying to allow users to reset their password, however i am getting the following error when an email address is submitted:
NoReverseMatch: Reverse for 'django.contrib.auth.views.password_reset_confirm' with arguments '()' and keyword arguments '{u'uidb36': 'xxxxx', u'token': u'xxxxxxxxxxxxx'}' not found. 0 pattern(s) tried: []
(the x's have been changed for the question)
The django.contrib.auth.views.password_reset_confirm def is here:
# Doesn't need csrf_protect since no-one can guess the URL
@sensitive_post_parameters()
@never_cache
def password_reset_confirm(request, uidb64=None, token=None,
template_name='registration/password_reset_confirm.html',
token_generator=default_token_generator,
set_password_form=SetPasswordForm,
post_reset_redirect=None,
current_app=None, extra_context=None):
"""
View that checks the hash in a password reset link and presents a
form for entering a new password.
"""
UserModel = get_user_model()
assert uidb64 is not None and token is not None # checked by URLconf
if post_reset_redirect is None:
post_reset_redirect = reverse('password_reset_complete')
else:
post_reset_redirect = resolve_url(post_reset_redirect)
try:
uid = urlsafe_base64_decode(uidb64)
user = UserModel._default_manager.get(pk=uid)
except (TypeError, ValueError, OverflowError, UserModel.DoesNotExist):
user = None
if user is not None and token_generator.check_token(user, token):
validlink = True
if request.method == 'POST':
form = set_password_form(user, request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect(post_reset_redirect)
else:
form = set_password_form(None)
else:
validlink = False
form = None
context = {
'form': form,
'validlink': validlink,
}
if extra_context is not None:
context.update(extra_context)
return TemplateResponse(request, template_name, context,
current_app=current_app)
When using the commented url as opposed to the url below it, the following error results:
NoReverseMatch: Reverse for 'django.contrib.auth.views.password_reset_confirm' with arguments '()' and keyword arguments '{u'uidb36': 'xxxxx', u'token': u'xxxxxxxxxxxxxx'}' not found. 1 pattern(s) tried: ['user/password/reset/confirm/(?P<uidb64>[0-9A-Za-z_\\-]+)/(?P<token>.+)/$']
Upvotes: 1
Views: 1741
Reputation: 748
I found out what was going on here.
I had in my templates folder a registration/ folder with code only supported by previous versions. So i updated it with 1.6.5 template files.
Also, not updating the admin files caused problems.
Upvotes: 0
Reputation: 8821
The first keyword parameter name of the view is uidb64
but you are passing uidb36
in the keyword arguments dict. Change your URL patterns and use the commented version. The method signature has changed in version 1.6.
Looking at your error message again, I think it's not an issue in your URL configuration, rather either in a view or template where you use reverse URL resolution. This is the django.core.urlresolvers.reverse
method or the url
template tag. You are probably passing there a keyword argument with the key uidb36
which needs to be changed to uidb64
.
Upvotes: 3
Reputation: 1951
Edited
Why is this line commented? :
#url(r'^user/password/reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm', name='password_reset_confirm'),
Upvotes: 0