@login_required
def object_changes(request, revision_id):
    revision = get_object_or_404(Revision, pk=revision_id)

    # we assume there's only one version per revision
    current_version = revision.version_set.all()[0]
    obj = current_version.object

    try:
        previous_version = get_for_object(obj) \
                                .filter(pk__lt=current_version.pk)[0]
        obj_prev = previous_version.object
    except __HOLE__:
        # first revision for an object
        previous_version = current_version
        obj_prev = obj

    context = {
        'object_prev': obj_prev,
        'object': obj,
        'previous_version': previous_version,
        'current_version': current_version,
        'revision': revision,
        'title': str(obj),
    }
    if obj.__class__ == Person:
        return render(request, 'workshops/person_diff.html', context)
    elif obj.__class__ == Event:
        return render(request, 'workshops/event_diff.html', context)
    else:
        context['verbose_name'] = obj._meta.verbose_name
        context['fields'] = [
            f for f in obj._meta.get_fields()
            if f.concrete and not f.is_relation
        ]
        return render(request, 'workshops/object_diff.html', context)

# ------------------------------------------------------------
dataset/ETHPy150Open swcarpentry/amy/workshops/views.py/object_changes