Skip to content

Commit 2abc281

Browse files
committed
Fixed TimeField not handling empty values
1 parent f01a3d9 commit 2abc281

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

rest_framework/fields.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,8 @@ def to_representation(self, value):
12041204
)
12051205

12061206
if output_format.lower() == ISO_8601:
1207+
if (isinstance(value, str)):
1208+
value = datetime.datetime.strptime(value, '%H:%M:%S').time()
12071209
return value.isoformat()
12081210
return value.strftime(output_format)
12091211

0 commit comments

Comments
 (0)