如何覆盖 django allauth 电子邮件模板 [英] How to override django allauth email templates

查看:17
本文介绍了如何覆盖 django allauth 电子邮件模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 allauth 版本 0.35.0 并且我想覆盖电子邮件模板来为它们制作我想要的 HTML 模板.allauth 登录和注册等页面没问题但我找不到任何电子邮件模板.

I'm using allauth version 0.35.0 and I want to override email templates to make my desired HTML template for them. No problem with allauth login and SignUp and etc. pages But I can't find any template for emails.

它只是路径 /templates/account/email/ 中的一个 .txt 文件.但是如何为 allauth 任务设置 HTML 消息,例如更改他们的电子邮件的密码等?

It's just a .txt file in path /templates/account/email/. But How can I set HTMLmessage for allauth tasks like changing password and etc. for their email messages?

任何帮助将不胜感激.

推荐答案

糟糕!给我丢脸!

这部分allauth文档 这说明:

in this part of allauth documentation This said that:

可以通过提供您自己的模板来更改发送的电子邮件(例如,在忘记密码或电子邮件确认的情况下).模板命名如下:

Emails sent (e.g. in case of password forgotten or email confirmation) can be altered by providing your own templates. Templates are named as follows:

account/email/email_confirmation_subject.txt

account/email/email_confirmation_message.txt

如果您想包含 HTML 表示,请按如下方式添加 HTML 模板:

In case you want to include an HTML representation, add an HTML template as follows:

account/email/email_confirmation_message.html

因此在我自己的模板中制作 email_confirmation_message.html 并使用 email_confirmation_message.txt 中使用的模板变量解决了问题.

So making email_confirmation_message.html in my own template and using template variables which are used in the email_confirmation_message.txt solved the problem.

这篇关于如何覆盖 django allauth 电子邮件模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆