Chapter 5. Custom Template Filters and Tags

In this chapter, we will cover the following topics:

  • Following conventions for your own template filters and tags
  • Creating a template filter to show how many days have passed since a post was published
  • Creating a template filter to extract the first media object
  • Creating a template filter to humanize URLs
  • Creating a template tag to include a template if it exists
  • Creating a template tag to load a QuerySet in a template
  • Creating a template tag to parse content as a template
  • Creating a template tag to modify request query parameters

Introduction

As you know, Django has an extensive template system with features such as template inheritance, filters to change the representation of values, and tags for presentational ...

Get Web Development with Django Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.