Skip to content

Commit

Permalink
Fixes #94: Catch ZoneInfoNotFoundError exception when populating time…
Browse files Browse the repository at this point in the history
…zones
  • Loading branch information
jeremystretch committed Aug 12, 2022
1 parent c64c451 commit 0257f2e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion timezone_field/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ class TimeZoneField(models.Field):
# existing migration files will need to be accomodated.
default_max_length = 63
default_pytz_tzs = [pytz.timezone(tz) for tz in pytz.common_timezones]
default_zoneinfo_tzs = [ZoneInfo(tz) for tz in pytz.common_timezones]
default_zoneinfo_tzs = []
for tz in pytz.common_timezones:
try:
default_zoneinfo_tzs.append(ZoneInfo(tz))
except ZoneInfoNotFoundError:

Check warning on line 45 in timezone_field/fields.py

View check run for this annotation

Codecov / codecov/patch

timezone_field/fields.py#L45

Added line #L45 was not covered by tests
# ZoneInfo does not yet exist for this timezone
pass

Check warning on line 47 in timezone_field/fields.py

View check run for this annotation

Codecov / codecov/patch

timezone_field/fields.py#L47

Added line #L47 was not covered by tests

def __init__(self, *args, **kwargs):
# allow some use of positional args up until the args we customize
Expand Down

0 comments on commit 0257f2e

Please sign in to comment.