django-password-reset邮箱重置密码
2019-04-16 10:10
120 查看
-
看了网上不少关于django-password-reset的教程,但个人感觉不适合新手操作,所以本篇文章希望让跟多的人看懂。
-
官网地址:https://django-password-reset.readthedocs.io/en/latest/quickstart.html
-
官网的提示:
-
接下来我就把上面官网的要求走上一遍
-
下载方式pip:pip install django-password-reset
把password_reset添加到setting.py的INSTALLED_APPS里面
- 把include(‘password_reset.urls’) 添加到setting.py下面的urls.py里面
- 把{% url “password_reset_recover” %} 放到你的进入密码重置页面里面。
- 在templates下面创建base.html,路径为templates/base.html
上面解释了官网的四个快捷步骤,接下来就联系一下
创建一个视图(views)函数
urls.py path('reset_passwords',views.reset_passwords,name='reset_passwords'), #创建一个进入重置密码的页面
views.py def reset_passwords(request): return render(request, 'polls/reset_passwords.html')
#按照要求把{% url "password_reset_recover" %}加入到该html里面 templates/reset_password.html <form method="post" action="#"> {%csrf_token%} </form> <h5>忘记密码了?</h5> <h5>点击<a href='{% url "password_reset_recover" %}'>这里</a>重置密码</h5>
运行结果
点击“这里”,url会自动进入http://127.0.0.1:8000/password_resetrecover/ ,password_resetrecover/是默认路径,并且会渲染templates/base.html
在base.html里面加入{% block content %}{% endblock content %}运行后就可以重置密码了
最重要的一点需要配置邮箱
EMAIL_HOST = 'smtp.qq.com' EMAIL_PORT = 25 #发件箱的smtp服务器端口 EMAIL_HOST_USER = '' # 你的 QQ邮箱 账号 EMAIL_HOST_PASSWORD = ''#QQ邮箱授权码 EMAIL_USE_TLS = True # 这里必须是 True,否则发送不成功 EMAIL_FROM = '' # # 你的 QQ邮箱 账号 DEFAULT_FROM_EMAIL = ''# 你的 QQ邮箱 账号
当然只有已经注册的auth用户才可以使用该功能,不然它会提示找不到信息
最主要的是,这只是简单的实现了该功能,
相关文章推荐
- 重置ubuntu的密码: Reset root password (Ubuntu Linux) without CD
- Django 修改重置密码并通过邮箱进行验证的思考
- 使用主机配置文件重置ESXi root密码VMWare: Reset ESXi root password con Host Profile
- yii2使用邮箱组件发送邮件信息 Sorry, we are unable to reset password for email provided
- Reset Django admin password
- 重置邮箱密码后,第三方程序调用Exchange发送失败
- django 重置admin密码
- django项目培训站-25-重置密码
- 网站登录时密码忘记,通过向邮箱发送验证链接实现重置密码的实现方法
- 转载-重设 Mysql 密码报错 You must reset your password ... 和 Your password does N
- 在设计DJANGO用户更改密码时,出现NoReverseMatch at /account/password-change/这种妖精如何办?
- zencart移站后批量替换数据库中网址、电子邮箱、重置用户密码
- 邮箱密码重置结构图
- Jquery仿邮箱的登录、密码type=“password”输入框默认值
- django第三方模块重置密码
- django 开发忘记密码通过邮箱找回功能示例
- MySQL用户密码过期登陆报错ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
- Password management in Django 密码管理,记忆线索
- Mac环境下mysql初始化密码问题--If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.
- mysql 设置不了短串密码怎么办 You must reset your password using ALTER USER statement before executing this statement.