Ticket #10898: conditional_view_processing.diff

File conditional_view_processing.diff, 1.2 KB (added by tomasz.elendt, 16 years ago)
  • docs/topics/conditional-view-processing.txt

     
    5959The two functions, to compute the ETag and the last modified time, will be
    6060passed the incoming ``request`` object and the same parameters, in the same
    6161order, as the view function they are helping to wrap. The function passed
    62 ``last_modified`` should return a standard datetime value specifying the last
     62``last_modified_func`` should return a standard datetime value specifying the last
    6363time the resource was modified, or ``None`` if the resource doesn't exist. The
    6464function passed to the ``etag`` decorator should return a string representing
    6565the `Etag`_ for the resource, or ``None`` if it doesn't exist.
     
    8686    from django.db.models import Max
    8787
    8888    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")
    9090
    9191You can then use this function to provide early detection of an unchanged page
    9292for your front page view::
Back to Top