updated timefield also

This commit is contained in:
mjparker777 2015-12-13 16:09:56 -07:00
parent 81775dfbae
commit fc08236ab8
2 changed files with 6 additions and 1 deletions

View File

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

View File

@ -1030,7 +1030,9 @@ 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, 00): '13:00:00',
None: None,
'': None,
}
field = serializers.TimeField()