[英]Django Allauth: How to customize confirmation email subject?
I was able to customize the confirmation email HTML template by adding this file into the templates folder:通过将此文件添加到模板文件夹中,我能够自定义确认 email HTML 模板:
templates/account/email/email_confirmation_signup_message.html
Now I'm trying to customize the subject of the email by adding the text I want inside this file:现在我正在尝试通过在此文件中添加我想要的文本来自定义 email 的主题:
templates/account/email/email_confirmation_signup_subject.txt
But it doesn't seem to do anything, I still get the default subject all the time.但它似乎没有做任何事情,我仍然一直得到默认主题。
Does anyone know what I'm doing wrong?有谁知道我做错了什么?
Many thanks!非常感谢!
Do in this way...这样做...
install django-mail-templated安装 django-mail-templated
base template file code...基本模板文件代码...
{{ TAG_START_SUBJECT }}
{% autoescape off %}
{% block subject %}
{% endblock %}
{% endautoescape %}
{{ TAG_END_SUBJECT }}
{% block subject %}
Hello User..
{% endblock %}
Change file name to this:- templates/account/email/email_confirmation_subject.txt
and inside write将文件名更改为:-
templates/account/email/email_confirmation_subject.txt
并在里面写入
{% load i18n %}
{% autoescape off %}
{% blocktrans %}Please Confirm Your E-mail Address or do whatever..{% endblocktrans %}
{% endautoescape %}
Maybe the problem comes with your urls.py file You need to indicate here the file you use to customize the subject of your email.可能问题出在您的 urls.py 文件中。您需要在此处指明用于自定义 email 主题的文件。
PasswordResetView.as_view(template_name='email_confirmation_signup_message.html', subject_template_name='email_confirmation_signup_subject.txt')
You have to add this two files... first: account/email/email_confirmation_signup_message.html您必须添加这两个文件...首先:account/email/email_confirmation_signup_message.html
{% include "account/email/email_confirmation_message.html" %}
second:第二:
account/email/email_confirmation_message.html帐户/电子邮件/email_confirmation_message.html
The template that you want.
and finally delete the two.txt file: account/email/email_confirmation_signup_message.txt account/email/email_confirmation_message.txt最后删除两个.txt文件:account/email/email_confirmation_signup_message.txt account/email/email_confirmation_message.txt
pd: if you copy the folder template/account from your virtual enviroment you have to delete the files over there as well. pd:如果您从虚拟环境中复制文件夹模板/帐户,则还必须删除那里的文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.