Setting a variable default datetime value in Django/python

Django comparisons almost always require timezone aware datetimes.

I tried with a None value but the comparison failed.

A workaround to keep this compatible is to use epoch and isoparse with the timezone in the ISO string.

from dateutil import parser
check_date = parser.isoparse("1970-01-01T00:00:00+03:00")


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

About Me

My name is Tasos Sangiotis and I work at Arpedon, an engineering company. This website is a collection of posts, essays and photos. They are mainly about travel, food and technical stuff. Occasionally I shoot photos. They are mostly on Instagram. If you choose to wander this wasteland do so with caution. Consider this your final warning. To contact me use [email protected]

Newsletter