summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2016-06-18 23:39:26 -0400
committerSimon Charette <charette.s@gmail.com>2016-07-08 12:35:34 -0400
commit8a4f017f4565c51c83aabb61a816e334e8638432 (patch)
treefa6f6a4fcaf158dd161ef85fa85c3072390626e6 /docs
parent082c52dbedd76c312cebf3b23e04c449a94c20b6 (diff)
Fixed #26348 -- Added TruncTime and exposed it through the __time lookup.
Thanks Tim for the review.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/database-functions.txt11
-rw-r--r--docs/ref/models/querysets.txt21
-rw-r--r--docs/releases/1.11.txt8
3 files changed, 40 insertions, 0 deletions
diff --git a/docs/ref/models/database-functions.txt b/docs/ref/models/database-functions.txt
index 20ceadde91..74198ed749 100644
--- a/docs/ref/models/database-functions.txt
+++ b/docs/ref/models/database-functions.txt
@@ -686,6 +686,17 @@ that deal with time-parts can be used with ``TimeField``::
truncate function. It's also registered as a transform on ``DateTimeField`` as
``__date``.
+.. class:: TruncTime(expression, **extra)
+
+.. versionadded:: 1.11
+
+ .. attribute:: lookup_name = 'time'
+ .. attribute:: output_field = TimeField()
+
+``TruncTime`` casts ``expression`` to a time rather than using the built-in SQL
+truncate function. It's also registered as a transform on ``DateTimeField`` as
+``__time``.
+
.. class:: TruncDay(expression, output_field=None, tzinfo=None, **extra)
.. attribute:: kind = 'day'
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index 6985da5ca6..36d791db0e 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -2674,6 +2674,27 @@ When :setting:`USE_TZ` is ``True``, datetime fields are converted to the
current time zone before filtering. This requires :ref:`time zone definitions
in the database <database-time-zone-definitions>`.
+.. fieldlookup:: time
+
+``time``
+~~~~~~~~
+
+.. versionadded:: 1.11
+
+For datetime fields, casts the value as time. Allows chaining additional field
+lookups. Takes a :class:`datetime.time` value.
+
+Example::
+
+ Entry.objects.filter(pub_date__time=datetime.time(14, 30))
+ Entry.objects.filter(pub_date__time__between=(datetime.time(8), datetime.time(17)))
+
+(No equivalent SQL code fragment is included for this lookup because
+implementation of the relevant query varies among different database engines.)
+
+When :setting:`USE_TZ` is ``True``, fields are converted to the current time
+zone before filtering.
+
.. fieldlookup:: hour
``hour``
diff --git a/docs/releases/1.11.txt b/docs/releases/1.11.txt
index 392ded70b8..0ed83a1da8 100644
--- a/docs/releases/1.11.txt
+++ b/docs/releases/1.11.txt
@@ -201,6 +201,10 @@ Models
* Added support for time truncation to
:class:`~django.db.models.functions.datetime.Trunc` functions.
+* Added the :class:`~django.db.models.functions.datetime.TruncTime` function
+ to truncate :class:`~django.db.models.DateTimeField` to its time component
+ and exposed it through the :lookup:`time` lookup.
+
Requests and Responses
~~~~~~~~~~~~~~~~~~~~~~
@@ -273,6 +277,10 @@ Database backend API
``lookup_type`` argument can be either ``'hour'``, ``'minute'``, or
``'second'``.
+* The ``DatabaseOperations.datetime_cast_time_sql()`` method is added to
+ support the :lookup:`time` lookup. It accepts a ``field_name`` and ``tzname``
+ arguments and returns the SQL necessary to cast a datetime value to time value.
+
Dropped support for PostgreSQL 9.2 and PostGIS 2.0
--------------------------------------------------