Version 1 (modified by anonymous, 11 years ago) (diff)


Here 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).

def last_update(request):
    """Returns the last logged update with the admin."""
    from django.contrib.admin.models import LogEntry
        entry = LogEntry.objects.all().order_by('-action_time')[0]
    except IndexError:
        entry = None
    return {'last_update': entry}

Once you have added this to TEMPLATE_CONTEXT_PROCESSORS in your, you can use the following in your templates:

Site last updated: <a href="{{ last_update.get_edited_object.get_absolute_url }}">{{ last_update.action_time|date:"j M Y" }}</a>
Back to Top