开发者

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/rese开发者_如何学Got/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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜