Audit trail is a simple Django app to track the database changes and maintain history in any application. It also provide history for many_to_many fields, with ready admin page.
Quick start
Install django-model-audit:
pip install django-model-audit
Add “audit_trail” to your INSTALLED_APPS:
INSTALLED_APPS = [ ... 'audit_trail', ]Add Middlewre:
MIDDLEWARE = [ ... 'audit_trail.middleware.AuditMiddleware' ]Run Migrate:
python manage.py migrate
Add an AuditTrail and manager to model you want to create history:
from audit_trail.history import AuditTrail, AuditManager class MyModel(models.Model): ... history = AuditTrail() objects = AuditManager.as_manager() class Meta: display_format = '{model_name.field_name}'To add admin screen for audit simply inherit AuditTrailAdmin in your model admin:
from audit_trail.admin import AuditTrailAdmin class MyModelAdmin(AuditTrailAdmin): ...Visit django model admin screen to get the history of particular model(Click on History button in that screen).
To get audit trail of many_to_many fields just send signal from your AppConfig class’ ready method:
from audit_trail.signals import audit_m2m_ready class MyappConfig(AppConfig): ... def ready(self): audit_m2m.ready.send(sender=self.__class__) ...To get audit trail logs in your django app import and call function get_audit_trail() like this:
from audit_trail.admin import get_audit_trail get_audit_trail(model_name, object_id)
Metadata
Release files for django-model-audit 0.1.9
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-model-audit-0.1.9.tar.gz | 28.0 kB | Details |
Release files / django-model-audit-0.1.9.tar.gz
| Download URL | django-model-audit-0.1.9.tar.gz |
|---|---|
| Size | 28.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97164b6b0701144f680d2672f2db776c67b4581c3cee08f3ab2298084060adf8
|
|
BLAKE2b-256 checksum How to use checksums |
cdb6dc21bc3ef3bb40cedfaf3bfd5d7c455c89c83ede71aff1655e043826ff14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |