summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2010-12-22 03:34:04 +0000
committerKaren Tracey <kmtracey@gmail.com>2010-12-22 03:34:04 +0000
commitb1f6a4d66fd7f987a41c1e1aaa43907d9d347ba6 (patch)
treebf6b4aa355633fbd97c55a1967b7169b8e764f42 /docs
parentf0cd656ee085863d3a37f1bfb8351486428b4df2 (diff)
Fixed #10154: Allow combining F expressions with timedelta values.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15018 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/releases/1.3.txt3
-rw-r--r--docs/topics/db/queries.txt12
2 files changed, 14 insertions, 1 deletions
diff --git a/docs/releases/1.3.txt b/docs/releases/1.3.txt
index 0bf212452e..7992c95e5f 100644
--- a/docs/releases/1.3.txt
+++ b/docs/releases/1.3.txt
@@ -235,6 +235,9 @@ requests. These include:
providing a :class:`~django.template.RequestContext` by
default.
+ * Support for combining :ref:`F() expressions <query-expressions>`
+ with timedelta values when retrieving or updating database values.
+
.. _HTTPOnly: http://www.owasp.org/index.php/HTTPOnly
.. _backwards-incompatible-changes-1.3:
diff --git a/docs/topics/db/queries.txt b/docs/topics/db/queries.txt
index 2141aa6e91..cbbf073d39 100644
--- a/docs/topics/db/queries.txt
+++ b/docs/topics/db/queries.txt
@@ -36,6 +36,7 @@ models, which comprise a Weblog application:
headline = models.CharField(max_length=255)
body_text = models.TextField()
pub_date = models.DateTimeField()
+ mod_date = models.DateTimeField()
authors = models.ManyToManyField(Author)
n_comments = models.IntegerField()
n_pingbacks = models.IntegerField()
@@ -566,10 +567,19 @@ You can also use the double underscore notation to span relationships in
an ``F()`` object. An ``F()`` object with a double underscore will introduce
any joins needed to access the related object. For example, to retrieve all
the entries where the author's name is the same as the blog name, we could
-issue the query:
+issue the query::
>>> Entry.objects.filter(authors__name=F('blog__name'))
+.. versionadded:: 1.3
+
+For date and date/time fields, you can add or subtract a ``datetime.timedelta``
+object. The following would return all entries that were modified more than 3 days
+after they were published::
+
+ >>> from datetime import timedelta
+ >>> Entry.objects.filter(mod_date__gt=F('pub_date') + timedelta(days=3))
+
The pk lookup shortcut
----------------------