Replace pytz with zoneinfo for timezone handling

Fixes ModuleNotFoundError by using Python's built-in zoneinfo module
instead of the external pytz dependency. zoneinfo is the standard
library solution for timezone handling in Python 3.9+.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Keith Smith
2026-01-09 08:32:38 -07:00
co-authored by Claude Sonnet 4.5
parent 8d5faa8a6e
commit 9dd5d9c154
2 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -153,14 +153,14 @@ class Task(models.Model):
"""Check if task is overdue.""" """Check if task is overdue."""
if self.due_date and self.status not in ('completed', 'cancelled'): if self.due_date and self.status not in ('completed', 'cancelled'):
from django.utils import timezone from django.utils import timezone
import pytz from zoneinfo import ZoneInfo
# Get current date in user's timezone # Get current date in user's timezone
try: try:
user_tz = pytz.timezone(self.user.timezone) user_tz = ZoneInfo(self.user.timezone)
user_now = timezone.now().astimezone(user_tz) user_now = timezone.now().astimezone(user_tz)
user_today = user_now.date() user_today = user_now.date()
except (pytz.UnknownTimeZoneError, AttributeError): except (Exception,):
# Fall back to UTC if user timezone is invalid or missing # Fall back to UTC if user timezone is invalid or missing
user_today = timezone.now().date() user_today = timezone.now().date()
+3 -3
View File
@@ -219,12 +219,12 @@ class DashboardView(View):
return redirect('login') return redirect('login')
# Get today's date in user's timezone # Get today's date in user's timezone
import pytz from zoneinfo import ZoneInfo
try: try:
user_tz = pytz.timezone(request.user.timezone) user_tz = ZoneInfo(request.user.timezone)
user_now = timezone.now().astimezone(user_tz) user_now = timezone.now().astimezone(user_tz)
today = user_now.date() today = user_now.date()
except (pytz.UnknownTimeZoneError, AttributeError): except (Exception,):
# Fall back to UTC if user timezone is invalid or missing # Fall back to UTC if user timezone is invalid or missing
today = timezone.now().date() today = timezone.now().date()