Python list to django javascript as text
<p>Hello my generated python output list is </p>

<pre><code>l = ["one","two","there"]
</code></pre>

<p>I am passing that to a django html script as {{list}}</p>

<p>in the html it is shown as </p>

<pre><code>[&amp;#39;one&amp;#39;,&amp;#39;two&amp;#39;,&amp;#39;three&amp;#39;
</code></pre>

<p>which i can't use for my javascript, how do i pass this correctly, even I tried json_dumps like </p>

<pre><code>l = json_dumps (["one","two","there"])
</code></pre>

<p>it just shows as following in html </p>

<pre><code>[&amp;quote;one&amp;quote;,&amp;quote;two&amp;quote;,&amp;quote;three&amp;quote;]
</code></pre>

<p>There are two steps here. Firstly, you need to make the view send valid JSON; you've done this with <code>json_dumps</code>.</p>

<p>Secondly, you need to ensure that the template outputs it without escaping. You do that by marking it as safe, with <code>{{ data|safe }}</code> (assuming your data is in a variable called <code>data</code>).</p>

javascript python django python-3.x