mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 00:19:53 +03:00
only parse date objects if dateutil is available
This commit is contained in:
parent
f223cf70e9
commit
6ecf7599a9
|
@ -102,16 +102,16 @@ class MessagePackParser(BaseParser):
|
||||||
raise ParseError('MessagePack parse error - %s' % unicode(exc))
|
raise ParseError('MessagePack parse error - %s' % unicode(exc))
|
||||||
|
|
||||||
def _decode_object(self, obj):
|
def _decode_object(self, obj):
|
||||||
if '__datetime__' in obj:
|
if dateutil_parser:
|
||||||
return dateutil_parser.parse(obj['as_str'])
|
if '__datetime__' in obj:
|
||||||
elif b'__date__' in obj:
|
return dateutil_parser.parse(obj['as_str'])
|
||||||
return dateutil_parser.parse(obj['as_str']).date()
|
elif b'__date__' in obj:
|
||||||
elif b'__time__' in obj:
|
return dateutil_parser.parse(obj['as_str']).date()
|
||||||
return dateutil_parser.parse(obj['as_str']).time()
|
elif b'__time__' in obj:
|
||||||
elif b'__decimal__' in obj:
|
return dateutil_parser.parse(obj['as_str']).time()
|
||||||
return decimal.Decimal(obj['as_str'])
|
if b'__decimal__' in obj:
|
||||||
else:
|
return decimal.Decimal(obj['as_str'])
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
class FormParser(BaseParser):
|
class FormParser(BaseParser):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user