This Django app logs changes to models objects in a simple and granular way. This app supports multi-tenant environments which use django-tenant-schemas.
Requirements
Python 3.4
Django 1.8
Installation (for environments without django-tenant-schemas)
Add “auditor” to your INSTALLED_APPS setting like this:
INSTALLED_APPS = (
...
'django_auditor',
)
Add an empty dict ‘AUDITOR’ on your settings:
AUDITOR = {}
Include the auditor URLconf in your project urls.py like this:
url(r'^auditor/', include('django_auditor.urls'))
Run python manage.py makemigrations to create the migration file for auditor model.
Run python manage.py migrate to apply the migration and create the Auditor model.
Installation (django-tenant-schemas environments)
Add “auditor” to your SHARED_APPS or TENANT_APPS setting like this:
SHARED_APPS = (
...
'django_auditor',
)
or
TENANT_APPS = (
...
'django_auditor',
)
Add a dict ‘AUDITOR’ on your settings, specify a ‘tenant’ key with the value of your tenant model:
AUDITOR = {'tenant':'customers.Client'}
Include the auditor URLconf in your project urls.py like this:
url(r'^auditor/', include('django_auditor.urls'))
Run python manage.py makemigrations to create the migration file for auditor model.
Run python manage.py migrate_schemas to apply the migration and create the Auditor model.
Usage and Examples
Create an instance of Audit passing request and the object you want to log, then call the method create(), update() or delete() to generate a log with the appropriate action: CREATE, UPDATE or DELETE.
First you have to import the Audit class:
from django_auditor.auditor import Audit
New object
new_car = Car(name='Civic', manufacturer='Honda', color='Red')
new_car.save()
auditor = Audit(request, new_car).create()
Update Object
change_car = Car.objects.get(name='Civic')
auditor = Audit(request, change_car)
change_car.name = 'City'
change_car.color = 'Yellow'
change_car.save()
auditor.update()
Delete Object
remove_car = Car.objects.get(name='City')
auditor = Audit(request, remove_car)
remove_car.delete()
auditor.delete()
Now open http://yoursiteURL/auditor to check your logs.
Release files for django-auditor 1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-auditor-1.00.tar.gz | 5.4 kB | Details |
Release files / django-auditor-1.00.tar.gz
| Download URL | django-auditor-1.00.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9deac6e1a0f789027074bb2f1f1b88c4904b210b6f22120d2bf52a318d5b769b
|
|
BLAKE2b-256 checksum How to use checksums |
a09d5cecf4e72cac74f5927ee3e4158300ae0fb4aca332f587aaf58c82617026
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |