django标记跨越多行

django标记跨越多行,django,django-templates,Django,Django Templates,我正在学习django教程,我注意到字符串文本中一直有\个字符。我以为在django模拟的\n。。。然后由于某些原因,标记无法正确呈现 上下文:从生成的模板通过sendgrid发送电子邮件 例如: {% load i18n %}{% autoescape off %} {% trans "Hi" %} {{ user.get_username }}, {% trans "We've received a request to reset your password. If you didn't

我正在学习django教程,我注意到字符串文本中一直有\个字符。我以为在django模拟的\n。。。然后由于某些原因,标记无法正确呈现

上下文:从生成的模板通过sendgrid发送电子邮件 例如:

{% load i18n %}{% autoescape off %}
{% trans "Hi" %} {{ user.get_username }},

{% trans "We've received a request to reset your password. If you didn't 
make\ this request, you can safely ignore this email. Otherwise, click the 
button\ below to reset your password." %}

{% block reset_link %}
    {{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid \
token=token %}
{% endblock reset_link %}
{% endautoescape %}
在电子邮件中看到:

{%trans“我们收到重置您密码的请求。如果您没有\ 此请求,您可以安全地忽略此电子邮件。否则,请单击按钮\ 在下面重置密码。“%}

{%url'密码\u重置\u确认'uidb64=uid\ 令牌=令牌%}

但这正确地呈现了电子邮件:

{% load i18n %}{% autoescape off %}
{% trans "Hi" %} {{ user.get_username }},

{% trans "We've received a request to reset your password. If you didn't 
make this request, you can safely ignore this email. Otherwise, click the 
button below to reset your password." %}

{% block reset_link %}
    {{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid   token=token %}
{% endblock reset_link %}
{% endautoescape %}
那么,有人能详细说明为什么另一个会这样做吗?因为根据我的理解,换行是这样做的:{{value | linebreaksbr}}

字符\允许python代码中的lign中断,使其更易于阅读,但除此之外,它被忽略\n是字符串中的换行符。那么,您是否可以解释为什么在第一个示例中使用\会导致它在电子邮件中被忽略而无法正确呈现?反斜杠仅在python(
*.py
)文件中被忽略(用于换行)。它在模板文件中不会被忽略。