summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/forms/fields.txt17
-rw-r--r--docs/ref/models/fields.txt17
-rw-r--r--docs/ref/utils.txt9
-rw-r--r--docs/releases/1.8.txt13
4 files changed, 53 insertions, 3 deletions
diff --git a/docs/ref/forms/fields.txt b/docs/ref/forms/fields.txt
index 0f13adc249..b63826d9b1 100644
--- a/docs/ref/forms/fields.txt
+++ b/docs/ref/forms/fields.txt
@@ -546,6 +546,23 @@ For each field, we describe the default widget used if you don't specify
The maximum number of decimal places permitted.
+``DurationField``
+~~~~~~~~~~~~~~~~~
+
+.. versionadded:: 1.8
+
+.. class:: DurationField(**kwargs)
+
+ * Default widget: :class:`TextInput`
+ * Empty value: ``None``
+ * Normalizes to: A Python :class:`~python:datetime.timedelta`.
+ * Validates that the given value is a string which can be converted into a
+ ``timedelta``.
+ * Error message keys: ``required``, ``invalid``.
+
+ Accepts any format understood by
+ :func:`~django.utils.dateparse.parse_duration`.
+
``EmailField``
~~~~~~~~~~~~~~
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 2429406d68..203241ae5f 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -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``
--------------
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt
index 5939ff6fb1..327f44bbfc 100644
--- a/docs/ref/utils.txt
+++ b/docs/ref/utils.txt
@@ -158,6 +158,15 @@ The functions defined in this module share the following properties:
``tzinfo`` attribute is a :class:`~django.utils.tzinfo.FixedOffset`
instance.
+.. function:: parse_duration(value)
+
+ .. versionadded:: 1.8
+
+ Parses a string and returns a :class:`datetime.timedelta`.
+
+ Expects data in the format ``"DD HH:MM:SS.uuuuuu"`` or as specified by ISO
+ 8601 (e.g. ``P4DT1H15M20S`` which is equivalent to ``4 1:15:20``).
+
``django.utils.decorators``
===========================
diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt
index fccf50bc70..3a7cfea8e7 100644
--- a/docs/releases/1.8.txt
+++ b/docs/releases/1.8.txt
@@ -54,9 +54,16 @@ New data types
~~~~~~~~~~~~~~
* Django now has a :class:`~django.db.models.UUIDField` for storing
- universally unique identifiers. There is a corresponding :class:`form field
- <django.forms.UUIDField>`. It is stored as the native ``uuid`` data type on
- PostgreSQL and as a fixed length character field on other backends.
+ universally unique identifiers. It is stored as the native ``uuid`` data type
+ on PostgreSQL and as a fixed length character field on other backends. There
+ is a corresponding :class:`form field <django.forms.UUIDField>`.
+
+* Django now has a :class:`~django.db.models.DurationField` for storing periods
+ of time - modeled in Python by :class:`~python:datetime.timedelta`. It is
+ stored in the native ``interval`` data type on PostgreSQL and as a ``bigint``
+ of microseconds on other backends. Date and time related arithmetic has also
+ been improved on all backends. There is a corresponding :class:`form field
+ <django.forms.DurationField>`.
Query Expressions
~~~~~~~~~~~~~~~~~