Django 密码重置 -DoesNotExist 异常

发布于 2024-11-10 06:21:19 字数 1485 浏览 3 评论 0原文

输入电子邮件地址并按下按钮后,我的 Django 网站的 password_reset 页面导致出现 DoesNotExist 异常。

密码重置功能所需的四个 URL 在(主项目)urls.py 中为:

(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')

以下是用于关联视图的代码:

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')

电子邮件地址已正确检查有效性,但重定向到 password_reset/done 却没有似乎会发生。 URL 保持为password_reset,但会导致DoesNotExist 异常,其值为“站点匹配查询不存在”。

URL 和模板似乎工作正常,并且在手动访问时,password_reset/done 显示正确。
引用的模板是原始 Django 模板的精确副本,仅添加了页眉/页脚。不使用自定义视图/模板的密码重置会导致相同的错误。

任何关于可能导致这种情况的想法将不胜感激。

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/

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.

, '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>.+)/

The following is the code used for the associated views:


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.

, 'appname.views.cust_password_reset_confirm'), (r'^reset/done/

The following is the code used for the associated views:


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.

, 'appname.views.cust_password_reset_complete')

The following is the code used for the associated views:

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

清晰传感 2024-11-17 06:21:19

该错误“站点匹配查询不存在”意味着 settings.py 中的 SITE_ID 与数据库中的实际 Site 对象不匹配。检查您网站的 id 属性,并确保其与 SITE_ID 相同。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文