2024-04-26 06:41:27 发布
网友
我在model DateField中有一个字段 所以当我在网页上呈现它的时候
12-30-2012
我需要
我试着用内部模板
{{ item.pub_date.strftime("%d.%m.%Y") }}
但是我收到了解析错误。在控制台上它工作得很好。 然后在模型中尝试了一种新的方法
get_pub_date(self): self.pub_date.strftime("%d.%m.%Y")
当我在tempalte中调用这个方法时,在解析模板时也会遇到同样的错误
使用date template filter:
{{ item.pub_date|date:"d.m.Y" }}
另请注意:
When used without a format string:
...the formatting string defined in the DATE_FORMAT setting will be used, without applying any localization.
使用date template filter:
另请注意:
^{pr2}$相关问题 更多 >
编程相关推荐