[英]Check whether datetime object agrees with today in jinja2
I would like to test whether a python datetime object agrees with today within the browser, using jinja2 我想使用jinja2在浏览器中测试python datetime对象是否与今天一致
Something like 就像是
{% if current_user.last_seen_datetime.date() == TODAY %}
how would I get TODAY? 我怎么会今天?
I found the simples solution is to add a function to the User class 我发现简单的解决方案是向User类添加一个函数
def show_paper_suggestions(self):
if self.last_seen_datetime is None:
return 1
else:
return (datetime.datetime.utcnow() - self.last_seen_datetime).days
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.