Filters
-
add
- adds
argto 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
ncharacters -
cut
- removes all instances of
string_to_cutfrom the value. - date - for formatting dates.
-
default
- used to provide a default string when the variable evaluates to
False. -
default_if_none
- outputs
defaultif 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
Trueif 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
ndecimal places. -
force_escape
- Almost identical to
escape. -
get_digit
- returns the digit
icharacters 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
scriptelement. - last - outputs the last element in a sequence.
- length - returns the length of a value.
-
length_is
- returns
Trueif the length of the value isn. -
linebreaks
- converts newlines to
<br>and<p>tags. -
linebreaksbr
- converts all newline characters in
valueto<br>tags. - linenumbers - prepends each line of text with a line number.
-
ljust
- left justifies a value within text of
ncharacters - 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
ncharacters - safe - indicates that the value is known to be safe and therefore does not need to be escaped.
-
safeseq
- applies the
safefilter 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_dateand the value. - title - capitalizes the first letter of each word in a value.
-
truncatechars
- truncates a value to
ncharacters and appends an ellipsis (…). -
truncatechars_html
- truncates a value to
ncharacters and appends an ellipsis (…). Smart about HTML tags. -
truncatewords
- truncates a value to
nwords and appends an ellipsis (…). -
truncatewords_html
- truncates a value to
nwords 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
ncharacters. -
yesno
- maps
True,False, andNoneto mapped values.
