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

Writing your own template filters


Let's dive into writing our own filters. It can be hard to come up with a great example of a useful filter since the Django team has included default filters that serve most common needs, but we'll build three that can be helpful or can be later modified to fit your specific needs.

Setting up a test application

To experiment with tags and filters, we need to set up a test application that we can use as a sandbox to test our code. Instead of mucking up any apps that we have created in the previous chapters, we'll create a new project.

Note

Why not create custom tags and filters for our ongoing application? Well, Django has covered most of the common needs you'll have, so we need to reach deeper and create some samples that can be used for these more specific cases where a custom library needs to be created.

Create a new project called customtags in /projects and then create a filtertest application. (If you're using Windows, create it in c:\projects.)

In the /projects...