django TypeError: can't subtract offset-naive and offset-aware datetimes code example
Example: Python can't subtract offset-naive and offset-aware datetimes
import dateutil, datetime, pytz
LastDate = dateutil.parser.parse('2020-06-06 00:00:00+00:00')
now = datetime.datetime.now()
# Remove the TimeZone extension.
if (now - LastDate.replace(tzinfo=None) ).days >1:
print("This works")
# OR, make current datetime aware of the timezone
now = pytz.utc.localize(now)
if (now - LastDate ).days >1:
print("This works too")