문제

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