Fixed #2443 -- Added DurationField.

A field for storing periods of time - modeled in Python by timedelta. It
is stored in the native interval data type on PostgreSQL and as a bigint
of microseconds on other backends.

Also includes significant changes to the internals of time related maths
in expressions, including the removal of DateModifierNode.

Thanks to Tim and Josh in particular for reviews.
This commit is contained in:
Marc Tamlyn 2014-07-24 13:57:24 +01:00
parent a3d96bee36
commit 57554442fe
26 changed files with 524 additions and 138 deletions

View file

@ -542,6 +542,23 @@ The default form widget for this field is a :class:`~django.forms.TextInput`.
:class:`FloatField` and :class:`DecimalField` classes, please
see :ref:`FloatField vs. DecimalField <floatfield_vs_decimalfield>`.
``DurationField``
-----------------
.. versionadded:: 1.8
.. class:: DurationField([**options])
A field for storing periods of time - modeled in Python by
:class:`~python:datetime.timedelta`. When used on PostgreSQL, the data type
used is an ``interval``, otherwise a ``bigint`` of microseconds is used.
.. note::
Arithmetic with ``DurationField`` works in most cases. However on all
databases other than PostgreSQL, comparing the value of a ``DurationField``
to arithmetic on ``DateTimeField`` instances will not work as expected.
``EmailField``
--------------