Reprinted from: Http://www.lidongkui.com/django-template-filter-table
First, form: lowercase
{{name | lower}}
Second, the filter can be nested, the string through three filters, the first filter is converted to lowercase, the second filter output the first letter, the third filter to convert the initial letter to uppercase
Label
{{Str|lower|first|upper}}
Three, the parameters of the filter
Show Top 30 characters
{{bio | truncatewords: ' 30 '}}
Formatting
{{pub_date | date: ' F J, Y '}}
Filter List
{{123|add: ' 5 '}} adds a value to value
{"AB ' CD" |addslashes}} single quote with escape number, typically used for output to JavaScript
{"ABCD" |capfirst}} First letter capitalized
{"ABCD" |center: "50"} outputs a string of the specified length and the value pair
{{"123spam456spam789" |cut: "Spam"}} find to delete the specified string
{{value|date: "F J, Y"}} format date
{{value|default: ' (n/A) '}} value does not exist, using the specified value
{{value|default_if_none: ' (n/A) '}} value is none, using the specified value
{{list variable |dictsort: ' Number '}} sort Small to large
{{list variable |dictsortreversed: ' Number '}} sort from large to small
{% if 92|pisibleby: "2"%} Determines whether the specified number is divisible
{{String|escape}} converted to HTML entity
{{21984124|filesizeformat}} is based on 1024, calculates the maximum value, retains 1 decimal places, and increases readability
{{List|first}} returns the first element of the list
{{"Ik23hr&jqwh" |fix_ampersands} & Switch to &
{{13.414121241|floatformat}} retains 1 decimal places, can be negative, several forms
{{13.414121241|floatformat: ' 2 '}} reserved 2 decimal places
{{23456 |get_digit: ' 1 '}} intercepts 1 digits at the specified position starting at single digit
{{list|join: ","}} to connect the list with the specified delimiter
{{List|length}} returns the number of lists
{% If list |length_is: "3"%} list number Specify value
{"ABCD" |linebreaks}} is used with a new line
、
Mark a Parcel
{"ABCD" |LINEBREAKSBR}} is used with a new line
Mark a Parcel
{{variable |linenumbers}} is a row number for each row in the variable
{"ABCD" |ljust: "50"}} The string is left in the specified width, and the other is filled with spaces
{"ABCD" |lower}} lowercase
{% for I in "1ABC1" |make_list%} abcde,{% endfor%} The number of characters in a string or number as a list
{{"abcdefghijklmnopqrstuvwxyz" |phone2numeric}} to convert a character to a corresponding number??
{{list or number |pluralize}} The plural form of the word, such as the number of list strings greater than 1, returns s, otherwise returns an empty string
{{List or number |pluralize: ' Es '}} specify ES
{{List or number |pluralize: ' Y,ies '}} specify ies to replace with Y
{{Object|pprint}} displays the value of an object
{{list |random}} returns a random item of the list
{{string|removetags: "BR P P"}} deletes the specified HTML tag in the string
{{string|rjust: ' 50 '}} put the string in the specified width to the right, and the other with a space padding
{{List |slice: ': 2 '}} Slice
{{string|slugify}} string left minus and underscore, other symbols deleted, spaces replaced with minus sign
{{3|stringformat: ' 02i '}} string format, using Python's string format syntax
{{"Eabcd" |striptags}} Stripped [x]html syntax tag
{{Time variable |time: ' P '}} Date Time part format
{{datetime|timesince}} How long has it been in the past given the date
{{datetime|timesince: ' Other_datetime '}} How much time has elapsed in two days
{{Datetime|timeuntil}} How much time has elapsed from the given date to the present, the difference from the above is the position before and after the 2nd period.
{{datetime|timeuntil: ' Other_datetime '}} How much time has elapsed in two days
{{"ABDSADF" |title}} Capitalize first letter
{{"A B C D E F" |truncatewords: "3"}} intercepts a specified number of words
{"111221" |truncatewords_html: "2"} intercepts the specified number of HTML tags and complements the complete
{{List|unordered_list}}
Multiple nested lists are displayed as an unordered list of HTML
{{String|upper}} all uppercase
Linkage URL Encoding
{{string|urlize}} changes URLs from plain text to clickable links.
{{string|urlizetrunc: ' 30 '}}, more than one number of characters intercepted.
{{"B C D E F" |wordcount}} Word number
{{"A B C D e F g h i j K" |wordwrap: "5"}} inserts a carriage return for each specified number of characters
{{boolean|yesno: ' Yes,no,perhaps '}} returns a string of three values, corresponding to non-null, NULL, None.
Django Template Filter