Password reset not working.

140 views
Skip to first unread message

heidi

unread,
Jan 30, 2014, 8:09:12 AM1/30/14
to django...@googlegroups.com
I'm using Django 1.6.1, and password reset is not working. When users enter their email, 502 occurs and this is sent to me:

Traceback (most recent call last):

  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 114, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)

  File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", line 99, in _wrapped_view
    response = view_func(request, *args, **kwargs)

  File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/views.py", line 158, in password_reset
    form.save(**opts)

  File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/forms.py", line 256, in save
    email = loader.render_to_string(email_template_name, c)

  File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py", line 164, in render_to_string
    return t.render(Context(dictionary))

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 140, in render
    return self._render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 134, in _render
    return self.nodelist.render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 840, in render
    bit = self.render_node(node, context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 854, in render_node
    return node.render(context)

  File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", line 447, in render
    six.reraise(*exc_info)

  File "/usr/local/lib/python2.7/dist-packages/django/template/defaulttags.py", line 433, in render
    url = reverse(view_name, args=args, kwargs=kwargs, current_app=context.current_app)

  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 509, in reverse
    return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))

  File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 429, in _reverse_with_prefix
    (lookup_view_s, args, kwargs, len(patterns), patterns))

NoReverseMatch: Reverse for 'auth_password_reset_confirm' with arguments '('MQ', u'3op-83ceb0bee07385a12e2a')' and keyword arguments '{}' not found. 0 pattern(s) tried: []


Relevant parts of urls.py:

    url(r'^login/$',
        auth_views.login,
        {'template_name': 'registration/login.html'},
        name='auth_login'),
    url(r'^logout/$',
        auth_views.logout,
        {'template_name': 'registration/logout.html'},
        name='auth_logout'),
    url(r'^password/change/$',
        auth_views.password_change,
        name='auth_password_change'),
    url(r'^password/change/done/$',
        auth_views.password_change_done,
        name='password_change_done'),
    url(r'^password/reset/$',
        auth_views.password_reset,
        name='auth_password_reset'),
    url(r'^password/reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
        auth_views.password_reset_confirm,
        name='password_reset_confirm'),
    url(r'^password/reset/complete/$',
        auth_views.password_reset_complete,
        name='auth_password_reset_complete'),
    url(r'^password/reset/done/$',
        auth_views.password_reset_done,
        name='password_reset_done'),

As far as I can see I have it correctly updated for the latest version of Django. What's wrong, and how do I fix it?

Me Sulphur

unread,
Jan 30, 2014, 8:34:23 AM1/30/14
to django...@googlegroups.com
url(r'^password/reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
        auth_views.password_reset_confirm,
        name='password_reset_confirm'),

Try setting 'name' for the above url block as 'auth_password_reset_confirm' 

heidi

unread,
Jan 30, 2014, 8:45:59 AM1/30/14
to django...@googlegroups.com
Thank you so much! Fixed now. How I missed that I have no idea.

Me Sulphur

unread,
Jan 30, 2014, 8:52:15 AM1/30/14
to django...@googlegroups.com
On an alternative note, it is always good to follow some kind of consistent conventions for things like naming. You might also want to prefix 'password_change_done' and 'password_reset_done' with 'auth_' for the sake of consistency.
Reply all
Reply to author
Forward
0 new messages