在django rest_auth密码重置中,默认电子邮件内容如下所示:-
之所以收到此电子邮件,是因为您请求在localhost:8000重置用户帐户的密码。
请转到以下页面并选择一个新密码:
http:// localhost:8000 / api / reset / Kih / 89a-23809182347689312b123 /
您的用户名,以防万一您忘记了:测试
感谢您使用我们的网站!
本地主机:8000团队
如何自定义此电子邮件的内容?
美好的一天,我正在尝试覆盖 Django allauth 的 password_reset_email 。问题是它成功覆盖,但数据(密码重置链接、站点名称和域名)未传递到电子邮件,这最终意味着用户无法重置密码,因为没有发送链接。
我的密码重置序列化器
class PasswordResetSerializer(PasswordResetSerializer):
def get_email_options(self):
return {
'subject_template_name': 'account/email/password_reset_key_subject.txt',
# 'email_template_name': 'account/email/password_reset_key.txt',
'html_email_template_name': 'account/password_reset_key.html',
}
Run Code Online (Sandbox Code Playgroud)
在我的templates/registration/password_reset_email.html
{% load i18n %}
{% autoescape off %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Confirm Your E-mail</title>
<style>
.body {
background-color: #f6f6f6;
padding: 30px;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
}
.content {
background-color: #FFFFFF;
color: #4d4d4d;
max-width: 400px;
padding: 20px;
margin: auto;
}
.title {
font-size: …Run Code Online (Sandbox Code Playgroud) django django-rest-framework django-allauth django-rest-auth