Tuesday, July 23, 2013

Reverse Lookup Failure on password change/reset views

I'm probably doing something stupid here but I can't see it.  I'm trying to implement password change and reset using auth, and I'm getting a "No Reverse Match" error for the password_reset_done view.  Normally that would mean that I forgot to creaste a url that calls this view, but I have, and other views in that block (like login) work fine.

So, in my main urls.py I have:


# Registration URLs
urlpatterns += patterns('',
    url(r'^registration/', include('registration.urls', namespace='registration')),
)

and there is no occurrence of 'registration' above this code in the urls.py.

Then, in the registration.urls.py:

from django.conf.urls import patterns, include, url
import django.contrib.auth.views
import registration.views

urlpatterns = patterns('',
    url(r'^login/$', 'django.contrib.auth.views.login', {}, 'login'),
    url(r'^logout/$', 'django.contrib.auth.views.logout', {}, 'logout'),
    url(r'^password_change/$', 'django.contrib.auth.views.password_change',
        {}, name='password_change'),
    url(r'^password_change_done/$', 'django.contrib.auth.views.password_change_done',
        {}, name='password_change_done'),

    url(r'^password_reset/$', 'django.contrib.auth.views.password_reset',
        {}, 'password_reset'),
    url(r'^password_reset_done/$', 'django.contrib.auth.views.password_reset_done',
        {}, 'password_reset_done'),
    url(r'^password_reset_confirm/(?P<uidb36>.+)/(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm',
        {}, 'password_reset_confirm'),
    url(r'^password_reset_complete/$', 'django.contrib.auth.views.password_reset_complete',
        {}, 'password_reset_complete'),

    url(r'^profile/$', registration.views.profile, {}, 'profile'),
    url(r'^profile/edit/$', registration.views.profile_edit, {}, 'profile_edit'),
...

and you can see that a url that invoked password_reset_done actually exists.

But on going to the password reset page: http://127.0.0.1:8000/registration/password_reset/  I get:

NoReverseMatch at /registration/password_reset/

Reverse for 'django.contrib.auth.views.password_reset_done' with arguments '()' and keyword arguments '{}' not found.
Request Method: GET
Request URL: http://127.0.0.1:8000/registration/password_reset/
Django Version: 1.5.1
Exception Type: NoReverseMatch
Exception Value:
Reverse for 'django.contrib.auth.views.password_reset_done' with arguments '()' and keyword arguments '{}' not found.
Exception Location: /usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py in _reverse_with_prefix, line 416
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:
['/home/peter/django-sites/simbiant/sched/django-src',   '/usr/local/lib/python2.7/dist-packages/pytz-2013b-py2.7.egg',   '/home/peter/django-sites',   '/home/peter/django-sites/simbiant/sched/django-src',   '/usr/lib/python2.7',   '/usr/lib/python2.7/plat-linux2',   '/usr/lib/python2.7/lib-tk',   '/usr/lib/python2.7/lib-old',   '/usr/lib/python2.7/lib-dynload',   '/usr/local/lib/python2.7/dist-packages',   '/usr/lib/python2.7/dist-packages',   '/usr/lib/python2.7/dist-packages/PIL',   '/usr/lib/python2.7/dist-packages/gst-0.10',   '/usr/lib/python2.7/dist-packages/gtk-2.0',   '/usr/lib/pymodules/python2.7',   '/usr/lib/python2.7/dist-packages/ubuntu-sso-client',   '/usr/lib/python2.7/dist-packages/ubuntuone-client',   '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',   '/usr/lib/python2.7/dist-packages/ubuntuone-couch',   '/usr/lib/python2.7/dist-packages/ubuntuone-installer',   '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
Server time: Wed, 24 Jul 2013 15:21:45 +0930

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/registration/password_reset/

Django Version: 1.5.1
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'django.contrib.flatpages',
 'debug_toolbar',
 'scheduler',
 'registration')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'debug_toolbar.middleware.DebugToolbarMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/views.py" in password_reset
  147.         post_reset_redirect = reverse('django.contrib.auth.views.password_reset_done')
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in reverse
  496.     return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in _reverse_with_prefix
  416.                 "arguments '%s' not found." % (lookup_view_s, args, kwargs))

Exception Type: NoReverseMatch at /registration/password_reset/
Exception Value: Reverse for 'django.contrib.auth.views.password_reset_done' with arguments '()' and keyword arguments '{}' not found.

Any ideas?  Let me know if you think posting Settings or Meta would help.

Pretty sure this is going to be a facepalm...

Cheers,

Peter

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment