I am using a DateTimeProperty on GAE Datastore.

date_posted = db.DateTimeProperty()

I then need to make a comparison with jinja2.

{% if i.date_posted is defined %}
  {{ i.date_posted.strftime('%d %b %Y') }}
{% else %}
  No
{% endif %}

On GAE SDK Console, my entry says:

date_posted (None)

But my comparison doesn't pick it up as null.

有帮助吗?

解决方案

You can try this:

{{ i.date_posted.strftime('%d %b %Y')  if i.date_posted != None  }}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top