`django-timezone-utils` provides a `TimeZoneField` for Django models, allowing storage and management of timezone information as strings (e.g., 'America/New_York'). It includes choices for displaying timezones and integrates seamlessly with Django's ORM and forms. The current version, 0.15.0, supports Django 4.x and Python 3, with releases typically aligning with new Django major versions.
pip install django-timezone-utilsVerified import paths — ran on the pinned version, not inferred.
Define a Django model with a `TimeZoneField` to store timezone information. The `choices_display` argument (available from v0.15.0) simplifies how timezone choices are presented in forms.
If upgrading from very old versions, consult the v0.11 release notes carefully. Update Django/Python, adjust imports (`TimeZoneField` is now from `timezone_utils.fields`), and remove any reliance on `SubfieldBase`.
Check the `django-timezone-utils` release notes or README for exact Django version compatibility and upgrade/downgrade your library version accordingly.
Upgrade to `django-timezone-utils >= 0.15.0` to use `choices_display`. Alternatively, for older versions, you can manually pass `choices=TIMEZONE_CHOICES_STANDARD` or `choices=TIMEZONE_CHOICES_WITH_GMT_OFFSET`.
Ensure `django-timezone-utils` is `0.11` or newer and compatible with your Django version. If you have custom fields, recheck their implementation against Django's latest field API without `SubfieldBase`.
Install the package using `pip install django-timezone-utils`.
Change your import statement to `from timezone_utils.fields import TimeZoneField`.