Passing data from Django to JavaScript using the Jinja template engine.
The code looks like this:
    return render(request,'OneApp/code1.html', {'test': a})

var strr2=[]
{% for val in test%}
{% endfor%}

It seems like everything is fine, Java displays:"100,200,200,300"
But if you do this:
I see that JS made the calculations:"100,200, Infinity, 300"

Tell me how to correctly transfer the string exactly as a string?
  • Stop perverting and find out what JSON is – Blue-eyed Butterfly Sep 26 '18 at 13:46
  • Blue-eyed Butterfly, Do I understand correctly that you propose to transfer data between Django and JavaScript via JSON? And Jinja turns out just a crutch? – Thoughtful Toucan Sep 26 '18 at 13:49
  • Thoughtful Toucan, worse crutch – Blue-eyed Butterfly Sep 26 '18 at 13:50
  • Why jinja in jang? – Disney's88 Sep 26 '18 at 13:53
  • [[sim3x]" – Thoughtful Toucan Oct 1 '18 at 12:23
  • Thoughtful Toucan, forget about YouTube as a resource for teaching programming

    Forget about non-off resources - its manual and docks will be enough for teaching janga
    – Disney's88 Oct 1 '18 at 12:25
  • Unfortunately, my level of English is not enough to understand the official documentation: ( – Thoughtful Toucan Oct 4 '18 at 10:18

1 Answers 1

Damn, I just asked a question and guessed it myself :( I had to put quotes...
{% for test in%}
{% endfor%}
  • but in general, such a construction can sometimes be useful to you when rendering to js
    {% endfor%}
    – Average Anaconda Sep 26 '18 at 17:27
  • Average Anaconda, I haven’t yet figured out what shielding is :( Or does everything that I send from Python fall under double shielding? If not | safe? – Thoughtful Toucan Oct 1 '18 at 12:30
  • Thoughtful Toucan, yes, it will be escaped, here’s documentation a> – Average Anaconda Oct 30 '18 at 10:38