caroline
caroline

Reputation: 291

Django Password Reset - DoesNotExist exception

The password_reset page of my Django site is causing a DoesNotExist exception after an email address is entered and the button pressed.

The four URLs required for the password reset function are in (the main project) urls.py as:

(r'^password_reset/$', 'appname.views.cust_password_reset'),
(r'^password_reset/done/', 'appname.views.cust_password_reset_done'),
(r'^reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$', 'appname.views.cust_password_reset_confirm'),
(r'^reset/done/$', 'appname.views.cust_password_reset_complete')

The following is the code used for the associated views:

def cust_password_reset(request):
    return password_reset(request, post_reset_redirect='password_reset/done',template_name='registration/password_reset_done.html')

def cust_password_reset_done(request):
    return password_reset_done(request,  template_name='registration/password_reset_done.html')

def cust_password_reset_confirm(request, uidb36=None, token=None):
    return password_reset_confirm(request, uidb36=uidb36, token=token,
    template_name='registration/password_reset_confirm.html',
    post_reset_redirect='registration/reset/done/')

def cust_password_reset_complete(request):
    return password_reset_complete(request,
    template_name='registration/password_reset_complete.html')

The email address is correctly checked for validity, but the redirect to password_reset/done doesn't appear to happen. The URL stays as password_reset, but causes a DoesNotExist exception with the value 'Site matching query does not exist'.

The URLs and templates seem to work properly and password_reset/done displays correctly when manually accessed.
The templates referenced are exact copies of the original Django templates, with just a header/ footer added. Password Resetting without using custom views/templates results in the same error.

Any ideas as to what could be causing this would be greatly appreciated.

Upvotes: 2

Views: 1116

Answers (1)

Chris Pratt
Chris Pratt

Reputation: 239460

That error, "Site matching query does not exist" means that the SITE_ID in settings.py does not match up with an actual Site object in the database. Check the id attribute for your site, and make sure it's the same as SITE_ID.

Upvotes: 2

Related Questions