【问题标题】:customising django allauth templates自定义 django allauth 模板
【发布时间】:2021-05-09 10:39:53
【问题描述】:

主要是尝试修改注册时发送的电子邮件验证,遵循 allauth 文档,当我更改 email_confirmation_message.txt 时,发送的电子邮件被修改,但是当我想使用 html 表示时,文档说使用 email_confirmation_message.html 但是它无法识别,而是发送默认电子邮件,或者如果我同时包含两者,它只会发送文本并忽略 html

email_confirmation_message.html:

{% extends "account/email/base_message.txt" %}
{% load account %}
{% load i18n %}

{% block content %}{% autoescape off %}{% user_display user as user_display %}{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}
<!doctype html>
                        <html>
                            <head>
                                <meta charset='utf-8'>
                                <meta name='viewport' content='width=device-width, initial-scale=1'>
                                <title>Snippet - GoSNippets</title>
                                <link href='https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/css/bootstrap.min.css' rel='stylesheet'>
                                <link href='' rel='stylesheet'>
                                
    
                                <script type='text/javascript' src=''></script>
                                <script type='text/javascript' src='https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js'></script>
                                <script type='text/javascript' src='https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha1/js/bootstrap.min.js'></script>
                            </head>
                            <body oncontextmenu='return false' class='snippet-body'>
                            <div style="display: none; font-size: 1px; color: #fefefe; line-height: 1px; font-family: 'Lato', Helvetica, Arial, sans-serif; max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden;"> We're thrilled to have you here! Get ready to dive into your new account. </div>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
            <table border="0" cellpadding="0" cellspacing="0" width="100%" style="max-width: 600px;">
                <tr>
                    <td bgcolor="#ffffff" align="left" style="padding: 20px 30px 40px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;">
                        <p style="margin: 0;">We're excited to have you get started on {{ site_domain }}. First, you need to confirm your account. Just press the button below.</p>
                    </td>
                </tr>
                <tr>
                    <td bgcolor="#ffffff" align="left">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td bgcolor="#ffffff" align="center" style="padding: 20px 30px 60px 30px;">
                                    <table border="0" cellspacing="0" cellpadding="0">
                                        <tr>
                                            <td align="center" style="border-radius: 3px;" bgcolor="#FFA73B"><a href={{ activate_url }} target="_blank" style="font-size: 20px; font-family: Helvetica, Arial, sans-serif; color: #ffffff; text-decoration: none; color: #ffffff; text-decoration: none; padding: 15px 25px; border-radius: 2px; border: 1px solid #FFA73B; display: inline-block;">Confirm Account</a></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr> <!-- COPY -->
                <tr>
                    <td bgcolor="#ffffff" align="left" style="padding: 0px 30px 0px 30px; color: #666666; font-family: 'Lato', Helvetica, Arial, sans-serif; font-size: 18px; font-weight: 400; line-height: 25px;">
                        <p style="margin: 0;">If that doesn't work, copy and paste the following link in your browser:</p>
                    </td>
                </tr> <!-- COPY -->
                
</table>
                            <script type='text/javascript'></script>
                            </body>
                        </html>
{% endblocktrans %}{% endautoescape %}{% endblock %}

【问题讨论】:

标签: django django-allauth


【解决方案1】:

好的,所以我想通了。您还必须更改 email_confirmation_signup_message.txt 到 email_confirmation_signup_message.html 并在其中将 {% include "account/email/email_confirmation_message.txt" %} 更改为 {% include "account/email/email_confirmation_message.html" %}

【讨论】:

  • 为什么需要使用{% include "account/email/email_confirmation_message.html" %}?您只需将模板移动到正确的文件夹即可。 templates/account/email/email_confirmation_message.html
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-12-27
  • 2019-08-01
  • 2021-10-31
  • 2020-08-01
  • 2020-07-27
  • 2015-07-05
  • 2018-02-06
相关资源
最近更新 更多