mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-03 13:14:30 +03:00
Resolve TimeField representation for midnight value. (#4107)
This commit is contained in:
parent
0795f7394c
commit
ebb4070467
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user