summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2009-04-28 13:28:57 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2009-04-28 13:28:57 +0000
commit0c1d38bdf4884121e322c557e09721af85c10eb3 (patch)
treed0b180eece17d255129b62f76da935a02c85efa4 /docs
parent6312de027911104825adbb0c553b4c5bfeb96b39 (diff)
Fixed #10898 -- Corrected minor error in conditional view processing example. Thanks to Tomasz Elendt for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10642 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/topics/conditional-view-processing.txt12
1 files changed, 5 insertions, 7 deletions
diff --git a/docs/topics/conditional-view-processing.txt b/docs/topics/conditional-view-processing.txt
index eb591a1d9c..33f34b2406 100644
--- a/docs/topics/conditional-view-processing.txt
+++ b/docs/topics/conditional-view-processing.txt
@@ -59,10 +59,10 @@ The ``condition`` decorator's signature looks like this::
The two functions, to compute the ETag and the last modified time, will be
passed the incoming ``request`` object and the same parameters, in the same
order, as the view function they are helping to wrap. The function passed
-``last_modified`` should return a standard datetime value specifying the last
-time the resource was modified, or ``None`` if the resource doesn't exist. The
-function passed to the ``etag`` decorator should return a string representing
-the `Etag`_ for the resource, or ``None`` if it doesn't exist.
+``last_modified_func`` should return a standard datetime value specifying the
+last time the resource was modified, or ``None`` if the resource doesn't
+exist. The function passed to the ``etag`` decorator should return a string
+representing the `Etag`_ for the resource, or ``None`` if it doesn't exist.
Using this feature usefully is probably best explained with an example.
Suppose you have this pair of models, representing a simple blog system::
@@ -83,10 +83,8 @@ add a new blog entry, you can compute the last modified time very quickly. You
need the latest ``published`` date for every entry associated with that blog.
One way to do this would be::
- from django.db.models import Max
-
def latest_entry(request, blog_id):
- return Entry.objects.filter(blog=blog_id).aggregate(Max("published"))
+ return Entry.objects.filter(blog=blog_id).latest("published").published
You can then use this function to provide early detection of an unchanged page
for your front page view::