Source

django-audittrail / audittrail / views.py

Full commit

from .models import Audit
from .forms import AuditForm

from django import http
from django.views.decorators.http import require_POST

@require_POST
def log_event(request):
    if not request.user.is_authenticated():
        return http.HttpResponseForbidden()

    form = AuditForm(request.POST)
    if form.is_valid():
        obj = form.save(commit=False)
        obj.user = request.user
        obj.save()

        return http.HttpResponse(obj.id, status=202)

    return http.HttpResponseBadRequest()