passwordresetform特殊用法html电子邮件模板未呈现

enyaitl3  于 2021-09-08  发布在  Java
关注(0)|答案(0)|浏览(156)

我的电子邮件模板(见下面的代码)无法呈现。您可以想象,注册后重置密码允许我按一个按钮向用户发送电子邮件,用标准密码重置消息以外的另一条消息重置其密码(见下文)。但它不是渲染,例如 <br> 他们仍在出现。有没有关于如何修复的想法?谢谢

from django.contrib.auth.forms import PasswordResetForm    

def reset_password_after_slack_registration(email, from_email, template='users/slack_account_password_reset_email.html'):
    """
    Reset the password for an user
    """
    form = PasswordResetForm({'email': email})
    form.is_valid()
    return form.save(from_email=from_email, email_template_name=template)

模板如下所示:

{% autoescape off %}
Hi {{ user.first_name }},
    <br>
    <br>

You have requested to set an account for your XYZ account that you have been using via Slack so far.<br>
For your XYZ account {{ user.email }}, you can <a href="https://example.com/accounts/google/login/">Sign in with Google</a> or set a a password, by clicking the link below:<br>

https://example.com{% url 'slack_account_password_reset_confirm' uidb64=uid token=token %}
<br><br>
If clicking the link above doesn't work, please copy and paste the URL in a new browser
window instead.
<br><br>
All the best,<br>
Your XYZ team
{% endautoescape %}

URL如下所示:


# Slack Accounts

path('slack/<uidb64>/<token>/',
     auth_views.PasswordResetConfirmView.as_view(template_name='users/slack_account_password_reset_confirm.html'),
     name='slack_account_password_reset_confirm'),

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题