Skip to content

Commit

Permalink
Resolve TimeField representation for midnight value. (#4107)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchristie committed May 10, 2016
1 parent 0795f73 commit ebb4070
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rest_framework/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ def to_internal_value(self, value):
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)
Expand Down
3 changes: 2 additions & 1 deletion tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ebb4070

Please sign in to comment.