19

I am trying to upgrade my webapp from Django 1.5 to Django 1.6 and as part of my set of django apps I am using django-registration 1.0.

After upgrading to Django 1.6 my app does not recognize the built-in authentication views any more. They are integrated in django registration as can be seen here, but they stopped working.

The Django release notes describe a change in the way these views should be integrated, when comparing that to the source code in the registration-app that looks fine.

I am introducing the registration urls as follows:

urlpatterns = patterns('',
     ...,
     url(r'^accounts/', include('registration.backends.default.urls')),
)

I get the an error when requesting the built in urls such as /accounts/password/change/

django.core.urlresolvers.NoReverseMatch

NoReverseMatch: Reverse for 'password_change_done' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

Does anyone have an idea why I get a no-reverse-match error?

yellowcap
  • 3,985
  • 38
  • 51

3 Answers3

35

The reason for this error is that the django.contrib.auth.views use different url names than the registration.auth_urls ones. To patch this problem, override the default urls until django-registration gets updated for django 1.6, and use the same names as Django.

from django.contrib.auth import views as auth_views


urlpatterns = patterns('',

      #override the default urls
      url(r'^password/change/$',
                    auth_views.password_change,
                    name='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='password_reset'),
      url(r'^password/reset/done/$',
                    auth_views.password_reset_done,
                    name='password_reset_done'),
      url(r'^password/reset/complete/$',
                    auth_views.password_reset_complete,
                    name='password_reset_complete'),
      url(r'^password/reset/confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
                    auth_views.password_reset_confirm,
                    name='password_reset_confirm'),

      #and now add the registration urls
      url(r'', include('registration.backends.default.urls')),
)
yellowcap
  • 3,985
  • 38
  • 51
Jay
  • 2,519
  • 5
  • 25
  • 42
  • I added the code Jay listed above to my registration/backends/simple/urls.py . I guess if you are using the default you would add it to registration/backends/default/urls.py. That worked for me. – teewuane Dec 14 '13 at 04:06
  • I did this also, and it works for me, however my templates are being ignored and the Django Admin templates are being used for password reset and change password. – Peter H Jan 09 '14 at 00:53
  • 3
    There is an open pull request for this issue on the django-registration repository. I would assume it will be integrated in the next release. Follow the discussion here: https://bitbucket.org/ubernostrum/django-registration/pull-request/63/ – yellowcap Feb 10 '14 at 10:10
  • Macropin's [django-registration fork](https://github.com/macropin/django-registration) has this fix. `pip uninstall django-registration`, then `pip install -e git+https://github.com/macropin/django-registration#egg=django-registration` – Rob Grant Aug 19 '14 at 14:33
  • P.s. I've asked the Django guys if they want to support django-registration, as providing the user/auth stuff seems incomplete without registration support, but they don't seem keen at the moment: https://groups.google.com/forum/#!topic/django-developers/yawNAWE4d1o – Rob Grant Aug 20 '14 at 07:11
8

Here is what I used:

url(r'', include('registration.backends.default.urls')),
url(r'', include('django.contrib.auth.urls')),

Django contrib now includes the missing urls

Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
0

Background

This issue seems to have cropped again for django-registration==1.0 and Django==1.6 and is documented here on the official django-registration pull request. I used the solution provided by @Jay but it didn't work specifically for the password reset part. I ended up with this error:

Error

password_reset_confirm() got an unexpected keyword argument 'uidb36'

Solution

Instead I pulled from another django-registration repository (as mentioned in the official pull request above) by doing the following:

  1. pip uninstall django-registration
  2. pip install git+git://github.com/macropin/django-registration.git
  3. Modify the code for 'urls.py' as mentioned in the post by @Jay (thanks!)
  4. Remember this is a temporary solution until the official django-registration support is updated for Django 1.6
Will
  • 11,276
  • 9
  • 68
  • 76
  • Isn't django-registration [no longer maintained](https://bitbucket.org/ubernostrum/django-registration/wiki/Home)? (I'd much rather this were made officially part of Django than South, but maybe that's something for 1.8!) – Rob Grant Jul 15 '14 at 10:59
  • I'm hoping the django-registration is taken over by someone (or maybe it won't be). I upgraded mine to 1.6 and since everything else was working, I used the fork to fix this issue. – Will Jul 15 '14 at 13:55