About Timezones

With the USE_TZ = True setting, Django uses timezones for the DateTimeField. The datetimes are saved in UTC timezone in the database.

Use the astimezone() method to get the time in a specific timezone:

>>> event.start
datetime.datetime(2019, 12, 31, 23, 0, 0, tzinfo=<UTC>)
>>> from django.utils import timezone
>>> tz = timezone.get_default_timezone()
>>> event.start.astimezone(tz)
datetime.datetime(2020, 1, 1, 0, 0, 0, 
tzinfo=<DstTzInfo 'Europe/Berlin' CET+1:00:00 STD>)

Tips and Tricks Programming Development Django 5.2 Django 4.2 Django 3.2 Python 3