About Creating Timezone-aware DateTimes

To create a date and time in the default timezone of the website, use:

1
2
3
4
>>> from datetime import datetime
>>> from django.utils.timezone import make_aware

>>> new_year = make_aware(datetime(2024, 1, 1))

Tips and Tricks Programming Development Django 4.2 Django 3.2 Django 2.2