Y
Y
YariKartoshe4ka2020-05-17 16:07:54
Django
YariKartoshe4ka, 2020-05-17 16:07:54

How to escape tags from a variable in Jinja?

There is some pattern. I want the variable containing html to be output as html, not just text. Is there any filter for this? I tried escape, but it doesn't work and it outputs the variable from the database as PS text, the data to which I added through the django admin panel<br>&nbsp;

{{ value|escape }}
<!-- Будет выведено обычным текстом <br> и &nbsp; -->

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2020-05-17
@YariKartoshe4ka

Obviously needed without shielding.
{{ value }}
If escaping is enabled by default, then you can
1) Mark the variable as safe and not escaping:
{{ value|safe }}
2) Or you can use the entire block:

{% autoescape false %}
    Autoescaping is inactive within this block
{% endautoescape %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question