In Django templates, normally you would use template inheritance to overwrite blocks from parent templates to include styles or scripts to the HTML document. This means that every main template of each view should be aware of all content that is inside; however, sometimes it is much more convenient to let the included templates decide what styles and scripts to load. It is possible to do this with Django Sekizai, which we will use in this recipe.
Using Django Sekizai
Getting ready
Before we begin with the recipe, follow these steps to get ready:
- Install django-classy-tags and django-sekizai to your virtual environment (and add them to the requirements/_base.txt):
(env)$ pip install -e git+https://github.com/divio/django...