这篇文章主要讲解了“Django怎么实现通过邮件找回密码的功能”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“Django怎么实现通过邮件找回密码的功能”吧!
今天学习当注册用户忘记密码时,通过发送邮件进行密码重置的功能,接下来开始:
首先修改django_project\django_project\settings.py,添加邮件相关的配置:

修改django_project\django_project\urls.py,添加重置密码url跳转规则:

在django_project\users\templates\users下新建password_reset.html

在django_project\users\templates\users下新建
password_reset_done.html:

在django_project\users\templates\users下新建
password_reset_confirm.html:

在django_project\users\templates\users下新建
password_reset_complete.html:

修改django_project\users\templates\users\login.html 添加忘记密码链接:

我们在django_project文件夹下运行python manage.py runserver 启动项目,访问http://127.0.0.1:8000主页点击登录,然后点击忘记密码:


点击密码重置后会提示邮件已发送:

进入邮箱查看密码重置的邮件:

点击邮件中密码重置的链接,输入新的密码提交:


重置成功后,点击现在登录即可登录到博客中:

感谢各位的阅读,以上就是“Django怎么实现通过邮件找回密码的功能”的内容了,经过本文的学习后,相信大家对Django怎么实现通过邮件找回密码的功能这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是天达云,小编将为大家推送更多相关知识点的文章,欢迎关注!