27.2 Custom Template Filters
Before jumping into building custom template tags, we detour and create a custom template filter. A filter is simply a tool that changes a string in the template. We saw the length, pluralize, title, date, and linebreaks filters (as well as a few others) in Chapter 4: Rapidly Producing Flexible HTML with Django Templates. In this section, we create our own filter.
The goal of our filter, called obfuscate, is to take an email and change it. Robots are known for scrapping the web in an attempt to find information, and by printing people’s emails on our website, we are doing them a disservice. Instead, we will print a string that is human understandable but (hopefully) unintelligible to robots. We will use it in startup_detail.html ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access