微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

自定义 django allauth 模板

如何解决自定义 django 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',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,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',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 %}

解决方法

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。