I'm currently working on a template tag that renders forms nicely. Therefore, I use some JavaScript libraries and css files. In the template I added the scripts:
<link rel="stylesheet" href="{% static 'xyz.css' %}"/>
<script lang="javascript" src="{% static 'xyz.js' %}"></script>
<div>
...
</div>
When rendering multiple forms on a singe site, those <links> and <script> are multiple times in the html document.
One possibility is to include them in the base template inside the <head> tag. But then they are in the html file even when they aren't needed.
Adding a {{ block head }} to the base template inside the <head> doesn't work either. For this {{ block.super }} is needed to append new js and css files, but {{ block.super }} doesn't work in includes (see http://ift.tt/1GUhHpR).
Aucun commentaire:
Enregistrer un commentaire