Django 密码重置 -DoesNotExist 异常
输入电子邮件地址并按下按钮后,我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该错误“站点匹配查询不存在”意味着 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 actualSite
object in the database. Check theid
attribute for your site, and make sure it's the same asSITE_ID
.