When I render a page using the Django template renderer, I can pass in a dictionary variable containing various values to manipulate them in the page using {{ myVar }}
{{ myVar }}
There are two things that worked for me inside Javascript:
'{{context_variable|escapejs }}'
and other: In views.py
from json import dumps as jdumps def func(request): context={'message': jdumps('hello there')} return render(request,'index.html',context)
and in the html:
{{ message|safe }}