Most Useful Filters
18 filters
- date for formatting dates.
-
default
used to provide a default string when the variable evaluates to
False. - filesizeformat converts a value in bytes to a friendly file size format.
-
floatformat
rounds a float to
ndecimal places. - intcomma adds thousand separators to a number. Needs {% load humanize %}, and django.contrib.humanize in INSTALLED_APPS
-
json_script
outputs a Python object as JSON inside of a
scriptelement. - length returns the length of a value.
- naturaltime says how long ago a datetime was. Needs {% load humanize %}, and django.contrib.humanize in INSTALLED_APPS
- pluralize returns a pluralization suffix.
- safe indicates that the value is known to be safe and therefore does not need to be escaped.
- slice returns a slice of a sequence.
- 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. -
truncatewords_html
truncates a value to
nwords and appends an ellipsis (…). Smart about HTML tags. - unlocalize forces one value to stay machine-readable. Needs {% load l10n %}
- urlencode escapes a string for use in a URL.
-
yesno
maps
True,False, andNoneto mapped values.
