fix TimeZoneChoiceField
This commit is contained in:
parent
84fb0aec70
commit
2864576c0c
|
|
@ -58,7 +58,11 @@ class TimeZoneChoiceField(serializers.ChoiceField):
|
||||||
super().__init__(choices=choices, **kwargs)
|
super().__init__(choices=choices, **kwargs)
|
||||||
|
|
||||||
def to_representation(self, value):
|
def to_representation(self, value):
|
||||||
return value.zone
|
if isinstance(value, str):
|
||||||
|
return value
|
||||||
|
elif isinstance(value, pytz.tzinfo.BaseTzInfo):
|
||||||
|
return value.zone
|
||||||
|
return None
|
||||||
|
|
||||||
def to_internal_value(self, data):
|
def to_internal_value(self, data):
|
||||||
return pytz.timezone(data)
|
return pytz.timezone(data)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user