Resolve TimeField representation for midnight value. (#4107)

This commit is contained in:
Tom Christie 2016-05-10 11:56:36 +01:00
parent 0795f7394c
commit ebb4070467
2 changed files with 3 additions and 2 deletions

View File

@ -1191,7 +1191,7 @@ class TimeField(Field):
self.fail('invalid', format=humanized_format)
def to_representation(self, value):
if not value:
if value in (None, ''):
return None
output_format = getattr(self, 'format', api_settings.TIME_FORMAT)

View File

@ -1063,7 +1063,8 @@ class TestTimeField(FieldValues):
'99:99': ['Time has wrong format. Use one of these formats instead: hh:mm[:ss[.uuuuuu]].'],
}
outputs = {
datetime.time(13, 00): '13:00:00',
datetime.time(13, 0): '13:00:00',
datetime.time(0, 0): '00:00:00',
'00:00:00': '00:00:00',
None: None,
'': None,