Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Simple audit for model instances in Django.

Project Description

This applications was created to audit model’s changes and maintain a log of them


You can install django-simple-audit in 2 ways: using pip or by install

$ pip install django-simple-audit

Then modify your, adding the package simple_audit in INSTALLED_APPS and in MIDDLEWARE_CLASSES add simple_audit.middleware.TrackingRequestOnThreadLocalMiddleware:




Tracking changes on a model

to audit a model you need import simple_audit and then register the model to be audited.

from django.db import models
import simple_audit

class Message(models.Model):

    title = models.CharField(max_length=50, blank=False)
    text = models.TextField(blank=False)

    def __unicode__(self):
        return self.text

class Owner(models.Model):

    name = models.CharField(max_length=50, blank=False)

    def __unicode__(self):

class VirtualMachine(models.Model):

    name = models.CharField(max_length=50, blank=False)
    cpus = models.IntegerField()
    owner = models.ForeignKey(Owner)
    so = models.CharField(max_length=100, blank=False)
    started = models.BooleanField()

    def __unicode__(self):

simple_audit.register(Message, Owner, VirtualMachine)

Advanced Usage (without httprequest or our middleware)

You can use django-simple-audit without an http request (for example in management command). In this situation there is no http request on thread context. To ensure gathering all modification on a single AuditRequest, you can specify it:

AuditRequest.new_request(path, user, ip)
    # my code... in same thread

Tracking m2m fields changes

Tracking m2m fields changes is still experimental, but you can enable it with the following variable:


You need to have at least one cache backend set in your django settings, otherwise the previous settings will be set to False.

    'default': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        'LOCATION': 'unique',
        'TIMEOUT': 300,


  • Django >= 1.8
  • django.contrib.contenttypes installed in INSTALLED_APPS


  • Improve tests


  • 0.2.2
    • Add support for Django 1.9.
  • 0.2.1
    • Drop South, require Django 1.8 or newer.
  • 0.2.0
    • Use South for migrations
  • 0.1.12
    • Created some simple tests
    • Enable many to many fiedls tracking (see Usage)
Release History

Release History

This version
History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_simple_audit_gizmag-0.2.2-py2-none-any.whl (20.6 kB) Copy SHA256 Checksum SHA256 py2 Wheel Jul 13, 2016
django-simple-audit-gizmag-0.2.2.tar.gz (22.3 kB) Copy SHA256 Checksum SHA256 Source Jul 13, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting