From 44f3ee77166bd5c0e8a4604f2d96015268dce100 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Sat, 7 Mar 2015 13:20:29 -0800 Subject: Fixed #9596 -- Added date transform for DateTimeField. --- docs/ref/models/querysets.txt | 21 +++++++++++++++++++++ docs/releases/1.9.txt | 6 ++++++ 2 files changed, 27 insertions(+) (limited to 'docs') diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 0ad944fe3a..0a0749d0c9 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -2463,6 +2463,27 @@ numbers and even characters. Generally speaking, you can't mix dates and datetimes. +.. fieldlookup:: date + +date +~~~~ + +.. versionadded:: 1.9 + +For datetime fields, casts the value as date. Allows chaining additional field +lookups. Takes a date value. + +Example:: + + Entry.objects.filter(pub_date__date=datetime.date(2005, 1, 1)) + Entry.objects.filter(pub_date__date__gt=datetime.date(2005, 1, 1)) + +(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:: year year diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt index 71960c5c3b..72e7fce2dc 100644 --- a/docs/releases/1.9.txt +++ b/docs/releases/1.9.txt @@ -233,6 +233,9 @@ Models :class:`~django.db.models.Avg` aggregate in order to aggregate over non-numeric columns, such as ``DurationField``. +* Added the :lookup:`date` lookup to :class:`~django.db.models.DateTimeField` + to allow querying the field by only the date portion. + CSRF ^^^^ @@ -346,6 +349,9 @@ Database backend API ``adapt_field_value()`` to mirror the ``convert_field_value()`` methods. +* To use the new ``date`` lookup, third-party database backends may need to + implement the ``DatabaseOperations.datetime_cast_date_sql()`` method. + Default settings that were tuples are now lists ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- cgit v1.3