我正在尝试实现password_reset(向用户发送消息以重置密码),但在写完电子邮件后,没有任何内容发送,用户被重定向到家...
我的view.py:
...
from django.contrib.auth.views import password_reset, password_reset_confirm
# Import the render shortcut to render the templates in response.
from django.shortcuts import render
# This view handles the password reset form URL /.
def reset(request):
return password_reset(request, template_name='le_site/reset.html',
email_template_name='le_site/password_reset_email.html',
subject_template_name='le_site/mdp-oublie_texte.txt ',
post_reset_redirect=reverse('success'))
# This view handles password reset confirmation links. See urls.py file for the mapping.
# This view is not used here because the password reset emails with confirmation links
# cannot be sent from this application.
def reset_confirm(request, uidb64=None, token=None):
return password_reset_confirm(request, template_name='le_site/password_reset_confirm.html',
uidb36=uidb36, token=token, post_reset_redirect=reverse('success'))
# This view renders a page with success message.
def success(request):
return render(request, "le_site/password_reset_complete.html")
...
我的urls.py:
from mysite.views import reset
...
url(r'reset$', 'reset', name='reset'),
url(r'^reset/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$',
'reset_confirm', name='password_reset_confirm'),
url(r'^success/$', 'success', name='success'),
...
我知道它并不重要,但我直接写http://localhost:8000/reset来访问重置表单页面。
为什么它不起作用? :( 为什么没有发送?为什么我会重定向到主页?
感谢&#39; S