I have a datetime object at my model. I am sending it to the view, but in html i don't know what to write in order to format it.
I am trying
{{ item.date.strftime("%Y-%m-%d")|escape }}
but I get
TemplateSyntaxError: Could not parse some characters: item.date.strftime|("%Y-%m-%d")||escape
when I am just using
{{ item.date|escape }}
it's working, but now with the format I want.
Any suggestions?
请尝试使用内置的Django 日期格式过滤器 :
{{ item.date|date:"Y M d" }}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.