I'm trying to output in bibtex format in Django and the template looks like this:
@{{ 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 }}}
}
The problem is with the {{{
or {{%
. One way to go around the problem is to add a space after the first {
, but that kind of tamper the format. What's the right way to escape {
in Django templates?
Have a look at the templatetag tag:
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.
What you are after is:
{% templatetag openvariable %}
Maybe there is a nicer solution because this does not increase readability...