我正在尝试实现Django内置的更改密码功能。在初始/用户/密码/重置页面上单击重置后,我收到以下错误:
[Errno 65]在create_connection
中的socket.py位置没有主机路由我使用的是标准网址:
url(r'^user/password/reset/$',
'django.contrib.auth.views.password_reset',
{'post_reset_redirect' : '/user/password/reset/done/'},
name="password_reset"),
(r'^user/password/reset/done/$',
'django.contrib.auth.views.password_reset_done'),
(r'^user/password/reset/(?P<uidb36>[0-9A-Za-z]+)-(?P<token>.+)/$',
'django.contrib.auth.views.password_reset_confirm',
{'post_reset_redirect' : '/user/password/done/'}),
(r'^user/password/done/$',
'django.contrib.auth.views.password_reset_complete'),
电子邮件设置:
EMAIL_USE_TLS = True
EMAIL_HOST = 'my.email.host'
EMAIL_PORT = 'myport'
EMAIL_HOST_USER = 'myemail@example.com'
EMAIL_HOST_PASSWORD = 'MYPW'
自定义重置模板:
{% extends "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>
{%endblock%}
自定义电子邮件模板:
{% load i18n %}
{% autoescape off %}
You're receiving this e-mail because you requested a password reset for your user account at {{ site_name }}.
Please go to the following page and choose a new password:
{% block reset_link %}
{{ protocol }}://{{ domain }}{% url "django.contrib.auth.views.password_reset_confirm" uidb36=uid token=token %}
{% endblock %}
Your username, in case you've forgotten: {{ user.username }}
Thanks for using our site!
The {{ site_name }} team.
{% endautoescape %}