2

I am getting an error when clicking on a password reset link on my django web app. People have asked this question before, the solution is given here - Django-nonrel + Django-registration problem: unexpected keyword argument 'uidb36' when resetting password

In my case I have it already set to base 64 encoding (see my urls.py below) but yet I'm still receiving this error message.

error

password_reset_confirm() got an unexpected keyword argument 'uidb36'

traceback

Traceback:
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
  75.             return view(request, *args, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  52.         response = view_func(request, *args, **kwargs)

Exception Type: TypeError at /accounts/password/reset/confirm/Mg-3ve-2379945fbf21a5bfbe8c/
Exception Value: password_reset_confirm() got an unexpected keyword argument 'uidb36'

in my urls.py

urlpatterns = patterns('',
...
url(r'^password/reset/confirm/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
                    auth_views.password_reset_confirm,
                    name='password_reset_confirm'),
...
)

Pip Freeze

Django==1.6.6
South==1.0
dj-database-url==0.3.0
django-admin-bootstrapped==2.0.4
django-autoslug==1.7.2
django-crispy-forms==1.4.0
django-endless-pagination==2.0
django-guardian==1.2.4
django-registration==1.0
pytz==2014.7
six==1.8.0
wsgiref==0.1.2
Community
  • 1
  • 1
cloudviz
  • 971
  • 4
  • 15
  • 40
  • Are you absolutely sure you are checking the correct code? Your error and your url pattern don't match. – Burhan Khalid Sep 28 '14 at 11:58
  • I'm definitely using this urls.py overriding the ones that were provided by django-registration. registration/auth_urls.py. I've given my full urls.py below. – cloudviz Sep 28 '14 at 13:12

2 Answers2

2

If you are using Django 1.6 or above than the code you are using is wrong as password reset was changed in Django 1.6.

Please read here https://docs.djangoproject.com/en/1.7/topics/auth/default/#django.contrib.auth.views.password_reset

You must change the template for your password reset email accordingly.

You must also change the urls accordingly

You have now

url(r'^password/reset/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$', 'django.contrib.auth.views.password_reset_confirm',
 {'post_reset_redirect' : '/accounts/password/done/'}),

Should be something like this

url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
    'django.contrib.auth.views.password_reset_confirm',
    name='password_reset_confirm'),
Ales Maticic
  • 1,895
  • 3
  • 13
  • 27
0

Here is my full urls.py

from django.conf.urls import patterns, include, url, include
from django.conf import settings
from django.conf.urls.static import static
from django.contrib.auth import views as auth_views

#Use for UNIQUE EMAIL
from registration.backends.default.views import RegistrationView
from registration.forms import RegistrationFormUniqueEmail

from django.contrib import admin
admin.autodiscover()

class RegistrationViewUniqueEmail(RegistrationView):
    form_class = RegistrationFormUniqueEmail


urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^$', 'Notes.views.home', name='home'),
    url(r'^profile/edit_profile', 'profiles.views.edit_profile', name='edit_profile'),
    url(r'^profile/(?P<slug>.*)/$', 'profiles.views.profile', name='profile'),             
    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'),
    url(r'^register', RegistrationViewUniqueEmail.as_view(),
                    name='registration_form'),
    url(r'^notes/(?P<year>[0-9]{4})/(?P<month>[0-9]{2})/(?P<slug>.*)/$',
        'Notes.views.note_detail',
        name = "note_detail" ),
    (r'^accounts/', include('registration.backends.default.urls')),
    url(r'^search/', 'Notes.views.search', name='search'),

)

if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
cloudviz
  • 971
  • 4
  • 15
  • 40