Question

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.

Was it helpful?

Solution

You can try this:

{{ i.date_posted.strftime('%d %b %Y')  if i.date_posted != None  }}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top