Skip to main content

Postgres audit triggers for Django

Project description

Postgres audit database via triggers

This app sets up a postgres audit database via triggers. See and for more information.


pip install postgres_audit_triggers


  • Add the postgres_audit_triggers app to INSTALLED_APPS before any apps that will be audited:
  • Install the postgres_audit_triggers middleware:

This middleware will add metadata to the audit row. To send metadata, the client must send a Postgres-Audit-Triggers-Meta header in the request to your Django view. The data within that header must be JSON serializable to a python dictionary.

  • Run migrations: python migrate postgres_audit_triggers

  • Add audit_trigger = True to the Model Meta options of the models that will be audited:

class MyAuditedModel(models.Model):
    class Meta:
        audit_trigger = True
  • Make migrations: python makemigrations
  • Run migrations: python migrate

Triggers introduce performance overhead. In certain cases, you may need to disable triggers while performing bulk operations. To turn off all triggers, a decorator is provided:

from postgres_audit_triggers.decorators import disable_triggers

def foo():
    # auditing will not be triggered on any database operations performed here

Project details

Download files

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

Files for postgres-audit-triggers, version 1.2.1
Filename, size File type Python version Upload date Hashes
Filename, size postgres-audit-triggers-1.2.1.tar.gz (11.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page