Sawradip Saha
Sawradip Saha

Reputation: 1431

Django: Avoid rendering as variable in template

I just started learning django for a few day. Django's templating system looks fascinating. but currently I am facing an issue. I need to print this kind of text in my webpage multiple times through template.

She {{ was }} a very  {{ helpful }} and {{ attractive}} girl.

But whenever I try to use this in template, it thinks those words are variable thaI am referring, and vanishes them from the output due to not getting a value. So the output becomes,

She a very and girl.

I completely understand that this is the intended behaviour, but in some case I am trying to tell the rendering engine to render that as it is. Is there any filter or workaround?? [ I have to use them inside the template, and they can't be passed through variables as string]

Upvotes: 0

Views: 307

Answers (1)

yagus
yagus

Reputation: 1445

You can use the verbatim template tag, which will stop rendering what is inside the tag. See docs here.

{% verbatim %}
    She {{ was }} a very  {{ helpful }} and {{ attractive}} girl.
{% endverbatim %}

Upvotes: 1

Related Questions