Ticket #10898: conditional_view_processing.diff
File conditional_view_processing.diff, 1.2 KB (added by , 16 years ago) |
---|
-
docs/topics/conditional-view-processing.txt
59 59 The two functions, to compute the ETag and the last modified time, will be 60 60 passed the incoming ``request`` object and the same parameters, in the same 61 61 order, as the view function they are helping to wrap. The function passed 62 ``last_modified `` should return a standard datetime value specifying the last62 ``last_modified_func`` should return a standard datetime value specifying the last 63 63 time the resource was modified, or ``None`` if the resource doesn't exist. The 64 64 function passed to the ``etag`` decorator should return a string representing 65 65 the `Etag`_ for the resource, or ``None`` if it doesn't exist. … … 86 86 from django.db.models import Max 87 87 88 88 def latest_entry(request, blog_id): 89 return Entry.objects.filter(blog=blog_id).aggregate(Max("published")) 89 return Entry.objects.filter(blog=blog_id).aggregate(Max("published")).get("published__max") 90 90 91 91 You can then use this function to provide early detection of an unchanged page 92 92 for your front page view::