Book Image

Django 1.0 Template Development

Book Image

Django 1.0 Template Development

Overview of this book

Table of Contents (17 chapters)
Django 1.0 Template Development
Credits
About the Author
About the Reviewers
Preface
Index

Built-in filter reference


Filters are easier to get your head around than tags, and so we'll start by reviewing them first. If you need to transform the output of your data in the template, you'll use a filter. It's important to remember that they don't modify the data, but only the way it is displayed. If you use the upper filter on a template variable, for example, the variable's output will be displayed in the upper case, but the variable's underlying value is not changed. If you use the variable again later in the template without the filter, it will not be displayed in the upper case.

To use a filter, type a pipe symbol after your variable name, then type the filter name, and any arguments it might require. No spaces are put between the variable and the filter name.

For example, if we have a template variable called myvariable and we want to use the upper filter, it would look like this in the template:

{{ myvariable|upper }}

add

add adds (mathematically, not via concatenation) the argument...