August 2016
Beginner to intermediate
717 pages
15h 24m
English
Django has the {% include %} template tag that renders and includes another template. However, there is a problem in some situations, where an error is raised if the template does not exist. In this recipe, we will see how to create a {% try_to_include %} template tag that includes another template and fails silently if there is no such template.
We will start again with the utils app that is installed and ready for custom template tags.
Advanced custom template tags consist of two things: the function that is parsing the arguments of the template tag and the Node class that is responsible for the logic of the template tag as well as the output. Perform the following ...
Read now
Unlock full access