From 798a971f200e807abc553be9ea803aed6e1e6045 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Tue, 14 Jun 2016 16:05:00 +0100 Subject: [PATCH] Simplfy TimeField passing through strings (#4197) * Simplfy TimeField passing through strings --- rest_framework/fields.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 5ed6d656c..aaf9ef14f 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -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)