Transition from pytz to zoneinfo
mainThis project supports both pytz and zoneinfo to facilitate the community transition.
Behavior of use_pytz
All exposed fields and functions accept an optional boolean use_pytz kwarg. If not specified, the default depends on your Django version:
- Django <= 3.X: Defaults to
True. - Django == 4.X: Defaults to the value of
django.conf.settings.USE_DEPRECATED_PYTZ(which defaults toFalse). - Django >= 5.X:
pytzsupport is dropped;use_pytzis effectively ignored as onlyzoneinfois supported.
Note: This package does not depend on pytz. If you set use_pytz=True, you must ensure pytz is installed in your environment.
Handling Missing Timezones in zoneinfo
zoneinfo searches the local system's timezone DB first, then the tzdata package. If you encounter ZoneInfoNotFoundError for valid timezones, install the tzdata package:
# Using poetry
poetry add tzdata
# Using pip
pip install tzdata