Merge pull request #3809 from areski/fix-timefield

Fixed TimeField not handling empty values
This commit is contained in:
Xavier Ordoquy 2016-01-11 12:28:28 +01:00
commit efe2c3739d
2 changed files with 3 additions and 0 deletions

View File

@ -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)

View File

@ -1032,6 +1032,7 @@ class TestTimeField(FieldValues):
}
outputs = {
datetime.time(13, 00): '13:00:00',
'00:00:00': '00:00:00',
None: None,
'': None,
}