Skip to content

Conversation

@ttak-apphelix
Copy link
Contributor

@ttak-apphelix ttak-apphelix commented Oct 29, 2025

Description

pytz got deprecated in Django 4.0 && has been completely removed in Django 5.0.
Django 4.2 had provided USE_DEPRECATED_PYTZ flag for pytz support which has now been completely removed in Django 5.0 as well.
Django now uses zoneinfo by default and datetime module use this under the hood now instead of pytz

Difference between datetime.timezone and zoneinfo

datetime.timezone and the zoneinfo package are both related to handling time zones in Python, but they serve slightly different purposes and have different use cases.

datetime.timezone

This is part of the standard library in Python.
It provides a simple way to represent a fixed offset from UTC (Coordinated Universal Time).
It doesn't have information about daylight saving time (DST) or historical changes in time zones.
It's suitable for scenarios where you only need to work with a constant offset, and historical changes in time zones are not important.

zoneinfo

The zoneinfo package is introduced in Python 3.9 as part of PEP 615.
It provides a more comprehensive and accurate way to handle time zones by including historical changes, daylight saving time transitions, and more.
It uses the IANA Time Zone Database, which is regularly updated to reflect changes in time zones around the world.
This package is suitable for applications that require precise handling of time zones, especially when dealing with historical dates.

Original Issue link:
#33980

Related PR:
#37148

Since it involves multiple files changes and as suggested in the PR planning to break that PR into multiple small PR.

Smaller PR link:

@ttak-apphelix ttak-apphelix requested a review from robrap October 29, 2025 11:31
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. See comments.

<%!
from django.utils.translation import gettext as _
from datetime import datetime, timedelta
import pytz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where datetime is used either, but this is a template, so I don't know if this could be used elsewhere?

  • Rather than risk it, it may make sense to leave this in.
  • Better yet, you can look back at the history and see where this was added, and if it should have been removed with earlier clean-up, or if it is used in a strange way.

<%namespace name='static' file='static_content.html'/>
<%!
import pytz
from zoneinfo import ZoneInfo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. See my other comment about templates. I'd like to ensure that there isn't any danger of removal of pytz. Depending on our findings, we may want to review or test all the /templates/ changes.
  2. Can you move this down to sort it appropriately?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants