Global revision log with django-reversion

If you ever needed to track changes to model instances in your Django code, you probably stumbled upon django-reversion (and if you didn't, I highly recommend it). It's a great way to add version control to your models and keep history of changes. For every model class registered with reversion the history view in Django administration panel gets the ability to rollback to previous versions. However, there is no central place to display a global log of all changes. Fortunately, it is quite easy to add.

Place the following code in one of your files:

from django.shortcuts import redirect
from reversion.models import Revision

class RevisionAdmin(admin.ModelAdmin):
    list_display = ('user', 'comment', 'date_created')
    search_fields = ('=user__username', '=user__email')
    date_hierarchy = ('date_created')

    def change_view(self, request, obj=None):
        self.message_user(request, 'You cannot change history.')
        return redirect('admin:reversion_revision_changelist'), RevisionAdmin)

Note: it would make no sense to edit revisions, hence the change view redirects back to list.