2๐
โ
Iโm not sure what you are trying to do, but if you want to use {{STATIC_URL}}
(or any kind of variable) inside js file, youโll have to inject it from the the template directly to the html, and only than use it on your script, for instance:
index.html
(rendered by django view):
<script>
var staticUrl = '{{STATIC_URL}}';
</script>
<script src="your-script.js"></script>
In your-script.js
:
console.log(staticUrl);
๐คOr Duan
Source:stackexchange.com