-
Book Overview & Buying
-
Table Of Contents
Django 1.0 Template Development
Tags can be trickier to understand than filters because they can do so much more. Tags allow for programming logic in your template code, such as looping through records with the {% for %} tag and performing conditional logic with the {% ifequal %} tag. If you're unsure whether to use a tag or a filter, think about what you're trying to accomplish. If it's simple display formatting, you'll probably use a filter; if it's something more involved, you'll probably need a tag.
To use a tag, you put a single bracket and percent symbol around the tag name. Many tags require an ending tag, such as the ifequal/endifequal tag in this example:
{% ifequal object.color 'blue' %}
The object is blue.
{% else %}
The object is not blue
{% endifequal %}This turns on or off the auto-escaping behavior in a Django template block. When escaping is enabled, HTML characters are turned into their character equivalents to prevent potentially malicious content from being written...
Change the font size
Change margin width
Change background colour