猿问

Django Allauth:如何自定义确认电子邮件主题?

通过将此文件添加到模板文件夹中,我能够自定义确认电子邮件 HTML 模板:

templates/account/email/email_confirmation_signup_message.html

现在我正在尝试通过在此文件中添加我想要的文本来自定义电子邮件的主题:

templates/account/email/email_confirmation_signup_subject.txt

但是好像也没什么用,我还是一直获取默认主题。

有谁知道我做错了什么?

非常感谢!


繁星点点滴滴
浏览 194回答 5
5回答

守着一只汪

对我来说,默认行为是将模板放在项目文件夹中,而不是放在特定的应用程序目录中api_project/templates/account/email/email_confirmation_subject.txt!对于可能只是因为 [example.com] 仍然出现在主题中的任何人,即使他们成功定制了templates/account/email/email_confirmation_subject.txt您需要配置的变量并且它并不明显它是ACCOUNT_EMAIL_SUBJECT_PREFIX = '[example.com]'

富国沪深

您必须添加这两个文件...首先:account/email/email_confirmation_signup_message.html{% include "account/email/email_confirmation_message.html" %}第二:帐户/电子邮件/email_confirmation_message.htmlThe template that you want.最后删除两个.txt文件:account/email/email_confirmation_signup_message.txt account/email/email_confirmation_message.txtpd:如果你从你的虚拟环境中复制文件夹模板/帐户,你也必须删除那里的文件。

不负相思意

将文件名更改为:- templates/account/email/email_confirmation_subject.txt 并在里面写入{% load i18n %}{% autoescape off %}{% blocktrans %}Please Confirm Your E-mail Address or do whatever..{% endblocktrans %}{% endautoescape %}

偶然的你

也许问题出在您的 urls.py 文件上 您需要在此处指明您用于自定义电子邮件主题的文件。PasswordResetView.as_view(template_name='email_confirmation_signup_message.html', subject_template_name='email_confirmation_signup_subject.txt')

Cats萌萌

这样做...安装 django-mail-templated基本模板文件代码...{{ TAG_START_SUBJECT }} {% autoescape off %} {% block subject %} {% endblock %} {% endautoescape %} {{ TAG_END_SUBJECT }}主模板文件代码...{% block subject %} Hello User.. {% endblock %}
随时随地看视频慕课网APP

相关分类

Python
我要回答