项目中与urls.py
相关的部分:
from django.conf.urls import include, url, patterns
urlpatterns = patterns('',
# other ones ...
url(r'^accounts/password/reset/$',
'django.contrib.auth.views.password_reset',
{'post_reset_redirect' : '/accounts/password/reset/done/'}),
url(r'^accounts/password/reset/done/$',
'django.contrib.auth.views.password_reset_done'),
url(r'^accounts/password/reset/(?P<uidb64>[0-9A-Za-z]+)-(?P<token>.+)/$',
'django.contrib.auth.views.password_reset_confirm',
{'post_reset_redirect' : '/accounts/password/done/'}),
url(r'^accounts/password/done/$',
'django.contrib.auth.views.password_reset_complete'),
)
根据请求,这是密码重置表格:
{% extends "site_base.html" %}
{% block title %}Reset Password{% endblock %}
{% block content %}
<p>Please specify your email address to receive instructions for resetting it.</p>
<form action="" method="post">
<div style="display:none">
<input type="hidden" value="{{ csrf_token }}" name="csrfmiddlewaretoken">
</div>
{{ form.email.errors }}
<p><label for="id_email">E-mail address:</label> {{ form.email }} <input type="submit" value="Reset password" /></p>
</form>
{% endblock %}
但是,每当我访问/accounts/password/reset/
页面并填写电子邮件后点击回车,页面立即重定向到/accounts/password/reset/done/
,并且不会发送电子邮件。
我的相关settings.py
变量:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'XXX@gmail.com'
EMAIL_HOST_PASSWORD = 'XXXXXX'
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
我知道电子邮件是可行的,因为我的使用django-registration-redux
的注册流程无瑕疵地运行。
有什么想法吗?