PasswordResetForm 特殊用途 HTML 电子邮件模板未呈现

时间:2021-07-09 14:11:30

标签: python html django django-authentication django-email

我的电子邮件模板(见下面的代码)没有呈现。您可以想象 reset_password_after_slack_registration 允许我按下按钮向用户发送电子邮件以使用标准密码重置消息以外的另一条消息重置他的密码(见下文)。但它不是渲染,例如<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 %}

网址如下所示:

# 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'),

0 个答案:

没有答案
相关问题