Tasos Sangiotis

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")

#python #django #til

- 1 toast