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

Chapter 7. Custom Tags and Filters

Django ships with a number of built-in template tags and filters that fit the needs of most web-publishing situations. Filters are typically used to modify the output of a value in the template, and tags let you do just about anything you want.

At some point in your development, you may come across a situation or need that cannot be handled by the default template tags and filters. Luckily, Django provides a way to write our own extensions to the template engine by creating custom tags and filters.

In this chapter, we will:

  • Review how the default template tags and filters are implemented

  • Learn the syntax for writing our own template tags and filters

  • Learn where to put our custom files in our project and how Django loads them

  • Create and implement custom filters to format currency, remove profanities, and test if an item is in a list

  • Create and implement custom tags to write output and introduce new variables into the context from within the template