1

Hello my generated python output list is

l = ["one","two","there"]

I am passing that to a django html script as {{list}}

in the html it is shown as

['one','two','three'

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

l = json_dumps (["one","two","there"])

it just shows as following in html

[&quote;one&quote;,&quote;two&quote;,&quote;three&quote;]
2
  • 1
    How are you passing that to the template? Please try to create a minimal reproducible example Commented Sep 27, 2016 at 7:31
  • yes, I have done those correctly . Daniel Rosema's method works {{list|safe}} instead of {{list}} anyway thanks for the comment Sayse .. Commented Sep 27, 2016 at 8:08

1 Answer 1

1

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

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

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Daniel can you give me your twitter of fb ..It's nice to be connected with you ..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.