django simple audit
This applications was created to audit model’s changes and maintain a log of them
Installation
You can install django-simple-audit in 2 ways: using pip or by setup.py install
$ pip install django-simple-audit
Then modify your settings.py, adding the package simple_audit in INSTALLED_APPS and in MIDDLEWARE_CLASSES add simple_audit.middleware.TrackingRequestOnThreadLocalMiddleware:
INSTALLED_APPS = [
'...',
'simple_audit',
]
MIDDLEWARE_CLASSES = [
'...',
'simple_audit.middleware.TrackingRequestOnThreadLocalMiddleware',
]
Usage
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):
return self.name
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):
return self.name
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)
try:
# my code... in same thread
finally:
AuditRequest.cleanup_request()
Tracking m2m fields changes
Tracking m2m fields changes is still experimental, but you can enable it with the following variable:
DJANGO_SIMPLE_AUDIT_M2M_FIELDS = True
You need to have at least one cache backend set in your django settings, otherwise the previous settings will be set to False.
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'unique',
'TIMEOUT': 300,
}
}
Dependencies
Django >= 1.8
django.contrib.contenttypes installed in INSTALLED_APPS
TODO
Improve tests
CHANGELOG
- 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)
Metadata
Release files for django-simple-audit-gizmag 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-simple-audit-gizmag-0.2.2.tar.gz | 22.3 kB | Without provenance | Details for django-simple-audit-gizmag-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_simple_audit_gizmag-0.2.2-py2-none-any.whl | Python 2 | none | any | Details for django_simple_audit_gizmag-0.2.2-py2-none-any.whl |
Total release size: 42.9 kB
Release files / django-simple-audit-gizmag-0.2.2.tar.gz
| Download URL | django-simple-audit-gizmag-0.2.2.tar.gz |
|---|---|
| Size | 22.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b393e395d7297d58f9553ff2d3e27d49ffa434b7886d338af5ef5b9df800f2f0
|
|
BLAKE2b-256 checksum How to use checksums |
74b28ded1b20655794fd2f236fb7b1675733181982e9ef80dae0a6d5bbcaf74c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_simple_audit_gizmag-0.2.2-py2-none-any.whl
| Download URL | django_simple_audit_gizmag-0.2.2-py2-none-any.whl |
|---|---|
| Size | 20.6 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
119544e5b981a9580c8dbad86b3a1f22cf8ee5c8c16fdaffe604bd92167e5524
|
|
BLAKE2b-256 checksum How to use checksums |
dc4865f99f1084228efad0b92998d05e48259de6ee84ebf41f39b4988a25d918
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-simple-audit-gizmag 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.