I have the same problem and am using an ugly solution with the notation "refactor later".
I put the js_top block at the top of the base template, and then any template that needs extra includes or a set of js variables can use this block.
Therefore, I have things like:
{% block js_top %} <script src="/jquery.useless-plugin.js" type="textjavascript"></script> <script type="textjavascript"> var myVar = {{my_variable.propriety}}; </script> {% endblock %}
Of course, if you need a more reliable and less "one-time" system, I would go with the created js.
source share