如何自定义django rest身份验证密码重置电子邮件内容/模板 [英] How to customize django rest auth password reset email content/template
问题描述
在django rest_auth密码重置中,默认电子邮件内容如下所示:-
In django rest_auth password reset, default email content look like following:-
您收到此电子邮件是因为您要求输入密码在本地主机上重置用户帐户:8000。
You're receiving this email because you requested a password reset for your user account at localhost:8000.
请转到以下页面并选择一个新密码:
Please go to the following page and choose a new password:
http:// localhost:8000 / api / reset / Kih / 89a-23809182347689312b123 /
您的用户名,以防万一您忘记了:test
Your username, in case you've forgotten: test
感谢您使用我们的网站!
Thanks for using our site!
本地主机:8000团队
The localhost:8000 team
如何自定义内容电子邮件?
How to customize content of this email ?
推荐答案
您需要连接自己的重置密码序列化程序( PASSWORD_RESET_SERIALIZER
),并使用自定义的保存
方法。
You need to hook up your own reset password serializer (PASSWORD_RESET_SERIALIZER
) with customized save
method.
(参考: https://github.com/Tivix/django-rest-auth/blob/v0.6.0/rest_auth/serializers.py#L123 )
不幸的是,由于使用了电子邮件选项,因此您需要覆盖整个保存方法。在下一版本(0.7.0)中,我们将使其更加灵活
Unfortunately you need to override the whole save method, due to how the e-mail options are used. We we'll make it a bit more flexible in the next release (0.7.0)
这篇关于如何自定义django rest身份验证密码重置电子邮件内容/模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!