gpt4 book ai didi

django - 如何在 Django 模板中表示 "{{"?

转载 作者:行者123 更新时间:2023-12-04 01:55:28 27 4
gpt4 key购买 nike

我试图在 Django 中以 bibtex 格式输出,模板如下所示:

@{{ pubentry.type }{,
author = {{% for author in pubentry.authors.all %}{{ author.first_name }} {{ author.middle_name }} {{ author.last_name }}{% if not forloop.last %} and {% endif %}
{% endfor %}},
title = {{{ pubentry.title }}},
journal = {{{ pubentry.journal }}}
}

问题出在 {{{{{% .解决该问题的一种方法是在第一个 { 之后添加一个空格。 ,但那种篡改格式。逃生的正确方法是什么 {在 Django 模板中?

最佳答案

看看 templatetag标签:

Output one of the syntax characters used to compose template tags.

Since the template system has no concept of "escaping", to display one of the bits used in template tags, you must use the {% templatetag %} tag.


你所追求的是:
{% templatetag openvariable %}
也许有更好的解决方案,因为这不会增加可读性......

关于django - 如何在 Django 模板中表示 "{{"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2794830/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com