簡體   English   中英

Django Allauth:如何自定義確認 email 主題?

[英]Django Allauth: How to customize confirmation email subject?

通過將此文件添加到模板文件夾中,我能夠自定義確認 email HTML 模板:

templates/account/email/email_confirmation_signup_message.html

現在我正在嘗試通過在此文件中添加我想要的文本來自定義 email 的主題:

templates/account/email/email_confirmation_signup_subject.txt

但它似乎沒有做任何事情,我仍然一直得到默認主題。

有誰知道我做錯了什么?

非常感謝!

這樣做...

  • 安裝 django-mail-templated

  • 基本模板文件代碼...

{{ TAG_START_SUBJECT }}
{% autoescape off %}
{% block subject %}
{% endblock %}
{% endautoescape %}
{{ TAG_END_SUBJECT }}

  • 主模板文件代碼...
{% block subject %}
Hello User..
{% endblock %}

將文件名更改為:- 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 文件中。您需要在此處指明用於自定義 email 主題的文件。

PasswordResetView.as_view(template_name='email_confirmation_signup_message.html', subject_template_name='email_confirmation_signup_subject.txt')

您必須添加這兩個文件...首先:account/email/email_confirmation_signup_message.html

{% include "account/email/email_confirmation_message.html" %}

第二:

帳戶/電子郵件/email_confirmation_message.html

The template that you want.

最后刪除兩個.txt文件:account/email/email_confirmation_signup_message.txt account/email/email_confirmation_message.txt

pd:如果您從虛擬環境中復制文件夾模板/帳戶,則還必須刪除那里的文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM