Skip to content Skip to sidebar Skip to footer

Escape Problem In Django Templates

Let's say that I have this string: s = '

Hello!

' When I pass this variable to a template, I want it to be rendered as raw html. Looking at the docs I see that I

Solution 1:

I think you should write as follows

{{s|escape|safe}}

it is ok for me

Solution 2:

You pretty much covered it, those are indeed all the ways to disable autoescaping.

Are you sure the value you are talking about is actually s = '<p>Hello!</p>'?

My hunch is that you have additional escaping somewhere in that string...

Solution 3:

Look at the HTML source code, is it escaped!??? I don't think so. It should be printing letter by letter, just like this:

<
p
>
H
E
L
L
O
<
/
>

Post a Comment for "Escape Problem In Django Templates"