django-common filters

django common filters
add : String addition, number addition, list addition, if it fails, it will return an empty string.
default: Provides a default value to be used when this value is considered False by django. For example: empty string, None. Different from default_if_none, this only uses the default value when the variable is None.
first: Returns the first value in the list.
last: Returns the last value in the list.
date: formatted date and time.
time: formatted time.
join: The same usage as join in python.
length: Returns the length of the string or array.
length_is: Whether the length of the string or array is the specified value.
lower: Program all strings to lowercase.
truncatechars: According to the parameters given later, truncate characters, if it exceeds, it is represented by ....
truncatewords: Same as truncatechars, this one is truncated by one word. The above two have xxx_html type, for html, truncate the characters in the tag, but not truncate the tag.
capfirst: Capitalize the first letter.
slice: slice list. The usage is the same as the slice operation in python, the interval is closed before opening and then open.
striptags: remove all html tags.
safe: turn off automatic escaping of variables
floatformat: Float format.
More can be found in the official documents 
: https://yiyibooks.cn/xx/Django_1.11.6/ref/templates/builtins.html
English: https: //docs.djangoproject.com/en/1.11/ref/templates/builtins/

date time filter format

Y: Four-digit year. For example: 1999 
y: Year with two digits. Such as: 99 
m: two-digit month. Such as: 01, 09 
n: One-digit month. Such as: 1, 9, 12 
d: two-digit day. Such as: 01,09,31 
j: One-digit day. For example: 1,9,31 
g: One-digit hour in 12-hour format. Such as: 1, 9, 12 
G: 1-digit hour in 24-hour format. Such as: 0, 8, 23 
h: two-digit hour in 12-hour format. Such as: 01 , 09, 12 
H: Two-digit hour in 24-hour format. Such as: 01,13,24 
i: minutes. From 00 -59 
s: seconds. from 00 -59

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325861748&siteId=291194637