Internal
Public Access
Add error handling for timezone conversion
Fixes 500 error when user timezone is invalid or missing. Now gracefully falls back to UTC if timezone conversion fails. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.5
parent
f2ca07d05d
commit
8d5faa8a6e
+7
-3
@@ -156,9 +156,13 @@ class Task(models.Model):
|
||||
import pytz
|
||||
|
||||
# Get current date in user's timezone
|
||||
user_tz = pytz.timezone(self.user.timezone)
|
||||
user_now = timezone.now().astimezone(user_tz)
|
||||
user_today = user_now.date()
|
||||
try:
|
||||
user_tz = pytz.timezone(self.user.timezone)
|
||||
user_now = timezone.now().astimezone(user_tz)
|
||||
user_today = user_now.date()
|
||||
except (pytz.UnknownTimeZoneError, AttributeError):
|
||||
# Fall back to UTC if user timezone is invalid or missing
|
||||
user_today = timezone.now().date()
|
||||
|
||||
return self.due_date < user_today
|
||||
return False
|
||||
|
||||
+7
-3
@@ -220,9 +220,13 @@ class DashboardView(View):
|
||||
|
||||
# Get today's date in user's timezone
|
||||
import pytz
|
||||
user_tz = pytz.timezone(request.user.timezone)
|
||||
user_now = timezone.now().astimezone(user_tz)
|
||||
today = user_now.date()
|
||||
try:
|
||||
user_tz = pytz.timezone(request.user.timezone)
|
||||
user_now = timezone.now().astimezone(user_tz)
|
||||
today = user_now.date()
|
||||
except (pytz.UnknownTimeZoneError, AttributeError):
|
||||
# Fall back to UTC if user timezone is invalid or missing
|
||||
today = timezone.now().date()
|
||||
|
||||
# Get filter parameters
|
||||
current_filter = request.GET.get('filter', 'all')
|
||||
|
||||
Reference in New Issue
Block a user