mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-23 01:57:00 +03:00
Simplfy TimeField passing through strings (#4197)
* Simplfy TimeField passing through strings
This commit is contained in:
parent
9406e45b2c
commit
798a971f20
|
@ -1196,7 +1196,7 @@ class TimeField(Field):
|
|||
|
||||
output_format = getattr(self, 'format', api_settings.TIME_FORMAT)
|
||||
|
||||
if output_format is None:
|
||||
if output_format is None or isinstance(value, six.string_types):
|
||||
return value
|
||||
|
||||
# Applying a `TimeField` to a datetime value is almost always
|
||||
|
@ -1209,8 +1209,6 @@ class TimeField(Field):
|
|||
)
|
||||
|
||||
if output_format.lower() == ISO_8601:
|
||||
if isinstance(value, six.string_types):
|
||||
value = datetime.datetime.strptime(value, '%H:%M:%S').time()
|
||||
return value.isoformat()
|
||||
return value.strftime(output_format)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user