summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
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
----------------------