I know how to send data from Django to html
with the view
def index(request):
coord = "[[1, 2], [2, 1]"
return render(request, 'index.html', {'coord': coord})
In the html
I able to use it any where like this {{ coord }}
, example :
<script type="text/javascript">
var geojsonObject = {
"coordinates": {{ coord }}
};
</script>
But when I try to do this in my 'index.js' I get an error:
Uncaught SyntaxError: Unexpected token '{'
index.html
<script src="{% static 'index.js'%}"></script>
index.js
var geojsonObject = {
"coordinates": {{ coord }}
};
I could keep everything in index.html
, but I find it not practical to debug. How can I pass my coor
object to the JavaScript through html?