我在GAE数据存储区上使用DateTimeProperty。
date_posted = db.DateTimeProperty()
然后我需要与jinja2进行比较。
{% if i.date_posted is defined %}
{{ i.date_posted.strftime('%d %b %Y') }}
{% else %}
No
{% endif %}
在GAE SDK控制台上,我的条目是:
date_posted(无)
但我的比较并没有把它当作零。
答案 0 :(得分:1)
你可以试试这个:
{{ i.date_posted.strftime('%d %b %Y') if i.date_posted != None }}