1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #26656 -- Added duration (timedelta) support to DjangoJSONEncoder.

This commit is contained in:
Will Hardy
2016-05-26 14:48:36 +02:00
committed by Tim Graham
parent a7b5dfd170
commit 8ef78b8165
7 changed files with 93 additions and 5 deletions

View File

@@ -297,6 +297,11 @@ The JSON serializer uses ``DjangoJSONEncoder`` for encoding. A subclass of
:class:`~datetime.time`
A string of the form ``HH:MM:ss.sss`` as defined in `ECMA-262`_.
:class:`~datetime.timedelta`
A string representing a duration as defined in ISO-8601. For example,
``timedelta(days=1, hours=2, seconds=3.4)`` is represented as
``'P1DT02H00M03.400000S'``.
:class:`~decimal.Decimal`, ``Promise`` (``django.utils.functional.lazy()`` objects), :class:`~uuid.UUID`
A string representation of the object.
@@ -304,6 +309,10 @@ The JSON serializer uses ``DjangoJSONEncoder`` for encoding. A subclass of
Support for ``Promise`` was added.
.. versionchanged:: 1.11
Support for :class:`~datetime.timedelta` was added.
.. _ecma-262: http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.15
YAML