de en es fr nl pl pt sv tr zh

server side

How to use a Python variable in an external Javascript (Django)

Groundblue

2025 Update: Check a security note below!One way to use a Python variable in an external Javascript is to declare the JS variable in the HTML template through context object, then pass this variable to the external script code :<script type="text/javascript">js_var_from_dj = "{{ django_var...