1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #2369: Corrected time zone validation on site API serializer

This commit is contained in:
Jeremy Stretch
2018-08-20 16:53:23 -04:00
parent c333af33dc
commit e1e41a768a
2 changed files with 4 additions and 4 deletions

View File

@ -108,10 +108,9 @@ class TimeZoneField(Field):
def to_internal_value(self, data):
if not data:
return ""
try:
return pytz.timezone(str(data))
except pytz.exceptions.UnknownTimeZoneError:
raise ValidationError('Invalid time zone "{}"'.format(data))
if data not in pytz.common_timezones:
raise ValidationError('Unknown time zone "{}" (see pytz.common_timezones for all options)'.format(data))
return pytz.timezone(data)
class SerializedPKRelatedField(PrimaryKeyRelatedField):