Filters
-
add
- adds
arg
to the value. - addslashes - adds backslashes before quotation marks to escape them.
- capfirst - capitalizes the first letter of a value.
-
center
- centers a value within text of
n
characters -
cut
- removes all instances of
string_to_cut
from the value. - date - for formatting dates.
-
default
- used to provide a default string when the variable evaluates to
False
. -
default_if_none
- outputs
default
if and only if the value isNone
. -
dictsort
- sorts a list of dictionaries by
key
. -
dictsortreversed
- reverse sorts a list of dictionaries by
key
. -
divisibleby
- returns
True
if the value is divisible byn
. - escape - escapes HTML characters.
- escapejs - escapes characters used in JavaScript strings.
- filesizeformat - converts a value in bytes to a friendly file size format.
- first - outputs the first element in a sequence.
-
floatformat
- rounds a float to
n
decimal places. -
force_escape
- Almost identical to
escape
. -
get_digit
- returns the digit
i
characters from the right side of the value. - iriencode - converts an IRI to a string that can be used in a URL.
-
join
- joins a list on
s
. Works just like Python’ss.join(value)
. -
json_script
- outputs a Python object as JSON inside of a
script
element. - last - outputs the last element in a sequence.
- length - returns the length of a value.
-
length_is
- returns
True
if the length of the value isn
. -
linebreaks
- converts newlines to
<br>
and<p>
tags. -
linebreaksbr
- converts all newline characters in
value
to<br>
tags. - linenumbers - prepends each line of text with a line number.
-
ljust
- left justifies a value within text of
n
characters - lower - lowercases the first letter of a value.
- make_list - converts the value to a list of characters.
- phone2numeric - converts letters to numbers for a phone number.
- pluralize - returns a pluralization suffix.
- pprint - Pretty prints a Python object. Used for debugging.
- random - outputs a random item from a sequence.
-
rjust
- right justifies a value within text of
n
characters - safe - indicates that the value is known to be safe and therefore does not need to be escaped.
-
safeseq
- applies the
safe
filter to each element of a sequence. - slice - returns a slice of a sequence.
- slugify - converts a string to a slug.
- stringformat - formats a string.
- striptags - strips HTML tags.
- time - for formatting times.
-
timesince
- outputs the amount of time between the value and
to_date
. -
timeuntil
- outputs the amount of time between
from_date
and the value. - title - capitalizes the first letter of each word in a value.
-
truncatechars
- truncates a value to
n
characters and appends an ellipsis (…). -
truncatechars_html
- truncates a value to
n
characters and appends an ellipsis (…). Smart about HTML tags. -
truncatewords
- truncates a value to
n
words and appends an ellipsis (…). -
truncatewords_html
- truncates a value to
n
words and appends an ellipsis (…). Smart about HTML tags. - unordered_list - creates an unordered HTML list from a Python list of lists.
- upper - uppercases the string.
- urlencode - escapes a string for use in a URL.
-
urlize
- converts URLs in a string to clickable links by wrapping them in an
<a>
tag. -
urlizetrunc
- like
urlize
, but truncates the link text. - wordcount - outputs the number of words in a value.
-
wordwrap
- inserts newline after every
n
characters. -
yesno
- maps
True
,False
, andNone
to mapped values.