Changes between Initial Version and Version 1 of LastUpdateContextProcessor


Ignore:
Timestamp:
Sep 1, 2006, 1:44:48 AM (18 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • LastUpdateContextProcessor

    v1 v1  
     1Here is a simple context processor that you can use to display the latest update to your site (using the history produced by the admin app).
     2{{{
     3def last_update(request):
     4    """Returns the last logged update with the admin."""
     5    from django.contrib.admin.models import LogEntry
     6    try:
     7        entry = LogEntry.objects.all().order_by('-action_time')[0]
     8    except IndexError:
     9        entry = None
     10    return {'last_update': entry}
     11}}}
     12
     13Once you have added this to TEMPLATE_CONTEXT_PROCESSORS in your settings.py, you can use the following in your templates:
     14{{{
     15Site last updated: <a href="{{ last_update.get_edited_object.get_absolute_url }}">{{ last_update.action_time|date:"j M Y" }}</a>
     16}}}
Back to Top