[英]Django generated email doesn't render properly
我正在嘗試修改django-registration中的密碼保留表,以包括超鏈接。 我為Activation_email.html使用了完全相同的代碼,但對於password_reset_email.html卻不起作用。 生成的電子郵件正在打印所有<html>的html標簽。 我想念什么?
以下是password_reset_email.html的代碼:
{% load i18n %}
<!doctype html>
<html lang="en">
{% blocktrans %}Hello,{% endblocktrans %}
{% blocktrans %}
To reset your password, please click the following link:
{% endblocktrans %}
<body>
<p>
<a href="http://{{site.domain}}{% url 'auth_password_reset_confirm' uid token %}">
Reset password
</a>
</p>
</body>
{% blocktrans %}
If you do not wish to reset your password, please ignore this message.
{% endblocktrans %}
{% blocktrans %}Thanks,{% endblocktrans %}
{% blocktrans %}Management Team{% endblocktrans %}
{# This is used by django.contrib.auth #}
這是Activation_email.html的代碼,用於比較。 這將產生正確的結果。
{% load i18n %}
<!doctype html>
<html lang="en">
<head>
<title>{{ site.name }} {% trans "registration" %}</title>
</head>
<body>
<p>
{% blocktrans with site_name=site.name %}
Hello!
</p>
<p>
We're ready to activate your account. All we need to do is make sure this is your email address.
{% endblocktrans %}
</p>
<p>
<a href="http://{{site.domain}}{% url 'registration_activate' activation_key %}">
Confirm email
</a>
</p>
<p>
{% blocktrans %}
If you didn't create a account, please just delete this email.
{% endblocktrans %}
</p>
</body>
</html>
聽起來好像電子郵件是作為文本發送的。 確保使用任何以html格式發送的方法。
如果您正在使用django.core.mail
send_mail
,則除了message
之外,還需要提供html_message
參數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.