mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 03:23:59 +03:00
Merge pull request #3809 from areski/fix-timefield
Fixed TimeField not handling empty values
This commit is contained in:
commit
efe2c3739d
|
@ -1204,6 +1204,8 @@ 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)
|
||||
|
||||
|
|
|
@ -1032,6 +1032,7 @@ class TestTimeField(FieldValues):
|
|||
}
|
||||
outputs = {
|
||||
datetime.time(13, 00): '13:00:00',
|
||||
'00:00:00': '00:00:00',
|
||||
None: None,
|
||||
'': None,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user