Karl Stulik
Karl Stulik

Reputation: 990

Can't make null value for DateTimeProperty

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.

Upvotes: 0

Views: 68

Answers (1)

radia
radia

Reputation: 1486

You can try this:

{{ i.date_posted.strftime('%d %b %Y')  if i.date_posted != None  }}

Upvotes: 1

Related Questions