本文介绍了触发密码重置电子邮件在django没有浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想能够使用django.contrib.auth.views.password_reset
发送密码重置电子邮件,但不使用浏览器 - password_reset需要一个填充的表单,有没有办法我可以以编程方式创建,发送电子邮件?
I want to be able to send a password reset email using django.contrib.auth.views.password_resetbut without using the browser - password_reset needs a populated form, is there a way I can create this programmatically and get the email sent?
推荐答案
from django.contrib.auth.forms import PasswordResetForm
def reset_password(email, from_email, template='registration/password_reset_email.html'):
"""
Reset the password for all (active) users with given E-Mail adress
"""
form = PasswordResetForm({'email': email})
return form.save(from_email=from_email, email_template_name=template)
这篇关于触发密码重置电子邮件在django没有浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!