2👍
As you mentioned in your own comment, you can save user_canvas_id
in a js variable in home.html
and access it in your js file. Something like this:
<head>
<script>var user_canvas_id = "{{ user_canvas_id }}"</script>
<script type="text/javascript" src="{% static 'canvas/canvasrender.js' %}"></script>
</head>
-1👍
I am confused to as what is going on. I thought that the script tag inserts the js file in between the “
<script> </script>
“
Kinda, but this is done client-side, by the browser who has no idea about the special meaning of curly braces in Django templates.
And static
in the context of Django means just that: That Django serves that file as-is, without running it through the template engine. (Which wouldn’t help here anyway, as for the JavaScript file in isolation, the value of user_canvas_ids
would be unknown, so the template engine couldn’t substitute anything useful for it.)
- SNS notifications to Browser
- Using Django URL's to send posted information to another page
- Required field validator does not work in Django on azure
Source:stackexchange.com