Combining a postgres audit trigger and django
Using a database trigger for auditing has various advantages over an app driven auditing.
- it means no extra traffic between app and db server
- the app can't bypass the auditing
- the saved audit data is the "truth" - it captures the changes on db level
In django-postgres Matthew Schinkel wrote an auditing app based on the same postgres audit trigger used here. But I wanted to have it as a standalone django app and using django.contrib.postgres. django-audit-trigger also has a different mechanism to manage audit subscriptions of models.
- django>=1.9 (currently the dev trunk)
- postgres>=9.4
django-audit-trigger uses a slightly modified version of the Audit trigger 91plus. Instead of hstore fields the trigger is modified to use jsonb fields.
todo
You might want to use the audit.models.mixins.AuditedModelMixin
for audit log query helpers.