Django Template Tags and Filters
The purpose of this website is to provide useful documentation on Django’s 73 template filters and 49 template tags. While the official documentation is very good, we have attempted to organize the tags and filters in a more meaningful way, and to give a better sense of how and if/when to use each one.
Filters
Coding Filters
addslashes
escape
escapejs
escapeseq
New in Django 5.0
force_escape
json_script
Most useful
linebreaks
linebreaksbr
pprint
safe
Most useful
striptags
Data Structure Filters
Date and Time Filters
date
Most useful
localtime
Needs {% load tz %}
naturalday
Needs {% load humanize %}, and django.contrib.humanize in INSTALLED_APPS
naturaltime
Needs {% load humanize %}, and django.contrib.humanize in INSTALLED_APPS
Most useful
time
Most useful
timesince
Most useful
timeuntil
Most useful
timezone
Needs {% load tz %}
utc
Needs {% load tz %}
Formatting Filters
capfirst
center
ljust
localize
Needs {% load l10n %}
lower
rjust
title
unlocalize
Needs {% load l10n %}
Most useful
upper
Logic Filters
default
Most useful
default_if_none
language_bidi
Needs {% load i18n %}
length_is
Removed in Django 5.1
yesno
Most useful
Number Filters
add
apnumber
Needs {% load humanize %}, and django.contrib.humanize in INSTALLED_APPS
divisibleby
filesizeformat
Most useful
floatformat
Most useful
get_digit
intcomma
Needs {% load humanize %}, and django.contrib.humanize in INSTALLED_APPS
Most useful
intword
Needs {% load humanize %}, and django.contrib.humanize in INSTALLED_APPS
length
Most useful
ordinal
Needs {% load humanize %}, and django.contrib.humanize in INSTALLED_APPS
wordcount
String Filters
cut
language_name
Needs {% load i18n %}
language_name_local
Needs {% load i18n %}
language_name_translated
Needs {% load i18n %}
linenumbers
phone2numeric
pluralize
Most useful
stringformat
truncatechars
truncatechars_html
truncatewords
truncatewords_html
Most useful
wordwrap
URL Filters
Tags
Coding Tags
Date and Time Tags
Formatting Tags
Logic Tags
cycle
Most useful
firstof
for
Most useful
for … empty
Most useful
if
Most useful
ifchanged
ifequal
Removed in Django 4.0
ifnotequal
Removed in Django 4.0
resetcycle
with
Most useful
Utility Tags
block
Most useful
blocktrans
Needs {% load i18n %}
blocktranslate
Needs {% load i18n %}
Most useful
cache
Needs {% load cache %}
Most useful
comment
Most useful
csp_nonce_attr
New in Django 6.1
csrf_token
Most useful
debug
extends
Most useful
filter
get_available_languages
Needs {% load i18n %}
get_current_language
Needs {% load i18n %}
get_current_language_bidi
Needs {% load i18n %}
get_language_info
Needs {% load i18n %}
get_language_info_list
Needs {% load i18n %}
get_media_prefix
Needs {% load static %}
get_static_prefix
Needs {% load static %}
include
Most useful
language
Needs {% load i18n %}
load
Most useful
lorem
now
partial
New in Django 6.0
Most useful
partialdef
New in Django 6.0
Most useful
querystring
New in Django 5.1
Most useful
regroup
static
Needs {% load static %}
Most useful
trans
Needs {% load i18n %}
translate
Needs {% load i18n %}
Most useful
url
Most useful
