Skip to main content

pypi actions codecov downloads clinicedc

django-audit-fields

This module has two model mixins that when used with a Django model adds a group of audit fields updated when a model instance is created and modified. This is one part of a strategy to be compliant with guidelines such as Good Clinical Practice (GCP), 21 CFR part 11, EU GDPR, UK GDPR, and the South African POPI Act. See the full list below of fields below.

This module includes django-revision, which tracks the source code revision, and is best used together with django-simple-history.

As of version 1.1.0, edc-utils is no longer a dependency of django-audit-fields.

Documentation: django-audit-fields.readthedocs.io

Requirements: DJ5.2+, py3.12+

Older versions

  • <=0.3.3 (DJ 3.1, py 3.7, 3.8)

  • >=0.3.4 (DJ 3.2+, py 3.9+)

  • >=0.3.14 (DJ4.2, py3.11) includes locale

Installation

pip install django-audit-fields

Add django-audit-fields to INSTALLED_APPS

INSTALLED_APPS = [
    "...",
    "django_audit_fields.apps.AppConfig",
    "..."]

Usage

Add model fields to track creation and modification dates, users and more on save.

Declare your model using AuditModelMixin

from django_audit_fields.models import AuditModelMixin
from simple_history.models import HistoricalRecords

class MyModel(AuditModelMixin,  models.Model):

    history = HistoricalRecord()

    class Meta(AuditModelMixin.Meta):
        pass

Preferably, use a UUID as primary key by declaring your model using AuditUuidModelMixin

from django_audit_fields.models import AuditUuidModelMixin
from simple_history.models import HistoricalRecords

class MyModel(AuditUuidModelMixin, models.Model):

    history = HistoricalRecord()

    class Meta(AuditUuidModelMixin.Meta):
        pass

Model mixins AuditModelMixin and AuditUuidModelMixin

The model mixin AuditUuidModelMixin sets the id fields to a UUIDField instead of an integer field.

Model mixins AuditModelMixin and AuditUuidModelMixin add audit fields:

Field

Field class

Update event

created

DateTimeField

only set on pre-save add

modified

DateTimeField

updates on every save

user_created

CharField

only set on pre-save add

user_modified

CharField

updates on every save

hostname_created

CharField

only set on pre-save add

hostname_modified

CharField

updates on every save

locale_created

CharField

only set on pre-save add

locale_modified

CharField

updates on every save

revision

RevisionField*

updates on every save

Release files for django_audit_fields 2.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django_audit_fields 2.0.6
File Size Uploaded
django_audit_fields-2.0.6.tar.gz 21.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django_audit_fields 2.0.6
File Interpreter ABI Platform
django_audit_fields-2.0.6-py3-none-any.whl Python 3 none any Details

Total release size:48.6 kB

Release files / django_audit_fields-2.0.6.tar.gz

Download URL django_audit_fields-2.0.6.tar.gz
Size 21.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9d593794cf04330eb50358359f83a5e949b32a6506ebe8d40a6b4a91de27c8b0
BLAKE2b-256 checksum
How to use checksums
cc879049f6fe034ad28ab25badf3b835dbaed9c67f8e87ff655219f1f5acc41f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.8

Release files / django_audit_fields-2.0.6-py3-none-any.whl

Download URL django_audit_fields-2.0.6-py3-none-any.whl
Size 26.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ece5579c0395186e8b111494c99c9a6738adfd884f85d86bc4fc13fa950e37f0
BLAKE2b-256 checksum
How to use checksums
13f2ed3346026e4df0db18fd38220640ea828423dce4490e30b6b92cf5227cdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.8

Release history Release notifications | RSS feed

This release

2.0.6 This release

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.3.16

2 release files

0.3.15

2 release files

0.3.11

2 release files

0.3.10

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.1.16

1 release file

0.1.15

1 release file

0.1.14

1 release file

0.1.13

1 release file

0.1.12

1 release file

0.1.11

1 release file

0.1.10

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page