Django: Getting Started Transcripts
Chapter: HTML Templates
Lecture: Common template filters

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Filters modify how context variables are rendered. This is the filter I used in the example before it converted the book's title into all uppercase.
0:12 There's also a lower tag that goes along with this. The first filter returns the first item in a collection and you guessed it,
0:21 there's a last that goes along with it pluralized, returns an S if what is being filtered is greater than one or a container with more than one item.
0:32 This is handy to construct sentences like you have three new messages you use pluralized instead of a giant if condition simply to make sure that
0:40 messages does or doesn't end in an S as is appropriate. It also supports an optional argument to specify how the pluralization is done.
0:51 So if you're paralyzing box, you can use the es suffix instead.


Talk Python's Mastodon Michael Kennedy's Mastodon