| | 1 | 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). |
| | 2 | {{{ |
| | 3 | def 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 | |
| | 13 | Once you have added this to TEMPLATE_CONTEXT_PROCESSORS in your settings.py, you can use the following in your templates: |
| | 14 | {{{ |
| | 15 | Site last updated: <a href="{{ last_update.get_edited_object.get_absolute_url }}">{{ last_update.action_time|date:"j M Y" }}</a> |
| | 16 | }}} |