To fix TypeError: can’t compare offset-naive and offset-aware datetimes with Python, we can use the utc.localize method to convert both times to aware datetimes.
For instance, we write
import datetime
import pytz
utc=pytz.UTC
challenge.datetime_start = utc.localize(challenge.datetime_start)
challenge.datetime_end = utc.localize(challenge.datetime_end)
to call utc.localize to convert datetime_start and datetime_end to time zone aware datetimes.
Then we can compare their values directly.