Skip to content

Commit 4e01796

Browse files
committed
Test for TimeField not handling empty values
1 parent a76c3ed commit 4e01796

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

rest_framework/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,7 @@ def to_representation(self, value):
12041204
)
12051205

12061206
if output_format.lower() == ISO_8601:
1207-
if (isinstance(value, str)):
1207+
if isinstance(value, six.string_types):
12081208
value = datetime.datetime.strptime(value, '%H:%M:%S').time()
12091209
return value.isoformat()
12101210
return value.strftime(output_format)

tests/test_fields.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,7 @@ class TestTimeField(FieldValues):
10321032
}
10331033
outputs = {
10341034
datetime.time(13, 00): '13:00:00',
1035+
'00:00:00': '00:00:00',
10351036
None: None,
10361037
'': None,
10371038
}

0 commit comments

Comments
 (0)