Code

Ticket #10898: conditional_view_processing.diff

File conditional_view_processing.diff, 1.2 KB (added by tomasz.elendt, 5 years ago)
Line 
1Index: docs/topics/conditional-view-processing.txt
2===================================================================
3--- docs/topics/conditional-view-processing.txt (revision 10620)
4+++ docs/topics/conditional-view-processing.txt (working copy)
5@@ -59,7 +59,7 @@
6 The two functions, to compute the ETag and the last modified time, will be
7 passed the incoming ``request`` object and the same parameters, in the same
8 order, as the view function they are helping to wrap. The function passed
9-``last_modified`` should return a standard datetime value specifying the last
10+``last_modified_func`` should return a standard datetime value specifying the last
11 time the resource was modified, or ``None`` if the resource doesn't exist. The
12 function passed to the ``etag`` decorator should return a string representing
13 the `Etag`_ for the resource, or ``None`` if it doesn't exist.
14@@ -86,7 +86,7 @@
15     from django.db.models import Max
16 
17     def latest_entry(request, blog_id):
18-        return Entry.objects.filter(blog=blog_id).aggregate(Max("published"))
19+        return Entry.objects.filter(blog=blog_id).aggregate(Max("published")).get("published__max")
20 
21 You can then use this function to provide early detection of an unchanged page
22 for your front page view::