I’m running a small app on Google App Engine with Python.
In the model I have a property of type DateTimeProperty, which is datetime.datetime. When it’s created there is no value (i.e. “None”).
I want compare if that datetime.datetime is None, but I can’t.
if object.updated_date is None or object.updated_date >= past:
object.updated_date = now
Both updated_date and past is datetime.datetime.
I get the following error.
TypeError: can’t compare datetime.datetime to NoneType
What is the correct way to do this?
You want
and, notor.You may also want to use
is None.EDIT:
Since you’ve determined that
object.updated_dateisn’tNone, this only other possibility is thatpastisNone.