O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

4.5.4 Controlling the Output of Variables with Template Filters title, length, and pluralize

We are now outputting the correct data, but it’s not very pretty: consider how neither django nor web is capitalized. Remember from Chapter 3 that, for alphabetization reasons, all of our tags are stored in the database in lowercase. When we display them to the user, we clearly don’t want to display them this way. We need to capitalize our content.

In addition to printing variables and providing template tags for logic, templates provide the ability to interact with variables via template filters. Template filters allow developers to sort, modify, and count lists; to format a Python date object into a pretty string; and to modify strings, such as to change ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required