Answer the question
In order to leave comments, you need to log in
How to pass a string, a mathematical expression, from Django to JS?
I pass data from Django to JavaScript using the Jinja template engine.
The code looks something like this:
a = ['200', '300']
return render(request, 'OneApp/code1.html', {'test' : a})
var strr2 = []
strr2.push('100')
strr2.push('200')
{% for val in test %}
strr2.push({{val}})
{% endfor %}
alert(strr2)
a = ['20/0', '300']
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question