|pypi| |actions| |codecov| |downloads|
django-audit-fields
-------------------
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
============
.. code-block:: bash
pip install django-audit-fields
Add both ``django_audit_fields`` and ``django_revision`` to INSTALLED_APPS
.. code-block:: python
INSTALLED_APPS = [
"...",
"django_revision.apps.AppConfig",
"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``
.. code-block:: python
from django_audit_fields.model_mixins import AuditModelMixin
class MyModel(AuditModelMixin, models.Model):
...
class Meta(AuditModelMixin.Meta):
pass
Preferably, use a UUID as primary key by declaring your model using ``AuditUuidModelMixin``
.. code-block:: python
from django_audit_fields.model_mixins import AuditUuidModelMixin
class MyModel(AuditUuidModelMixin, models.Model):
...
class Meta(AuditUuidModelMixin.Meta):
pass
The model mixins ``AuditModelMixin`` and ``AuditUuidModelMixin``:
* add audit fields (created, modified, user_created, user_modified, hostname_created, hostname_modified);
The model mixin ``AuditUuidModelMixin`` also
* sets the id fields to a ``UUIDField`` instead of an integer;
Most models require an audit trail. If so, add the ``HistoricalRecord`` model manager from ``django-simple-history``:
.. code-block:: python
from simple_history.models import HistoricalRecords
class MyModel(AuditUuidModelMixin, models.Model):
...
history = HistoricalRecords()
Notes
=====
User created and modified fields behave as follows:
* created is only set on pre-save add
* modified is always updated
.. |pypi| image:: https://img.shields.io/pypi/v/django-audit-fields.svg
:target: https://pypi.python.org/pypi/django-audit-fields
.. |codecov| image:: https://codecov.io/gh/erikvw/django-audit-fields/branch/develop/graph/badge.svg
:target: https://codecov.io/gh/erikvw/django-audit-fields
.. |downloads| image:: https://pepy.tech/badge/django-audit-fields
:target: https://pepy.tech/project/django-audit-fields
.. |actions| image:: https://github.com/erikvw/django-audit-fields/actions/workflows/build.yml/badge.svg
:target: https://github.com/erikvw/django-audit-fields/actions/workflows/build.yml
Raw data
{
"_id": null,
"home_page": null,
"name": "django-audit-fields",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": "Erik van Widenfelt <ew2789@gmail.com>",
"keywords": "django, clinicedc, edc, clinical trials, research, data management, esource",
"author": null,
"author_email": "Erik van Widenfelt <ew2789@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/3a/56/95c1fb408b87977dc81f3aac9ec8e0b1d45830eda5551d2ffc822186cf97/django_audit_fields-1.1.0.tar.gz",
"platform": null,
"description": "|pypi| |actions| |codecov| |downloads|\n\ndjango-audit-fields\n-------------------\n\nDJ5.2+, py3.12+\n\nOlder VERSIONs\n==============\n* <=0.3.3 (DJ 3.1, py 3.7, 3.8)\n* >=0.3.4 (DJ 3.2+, py 3.9+)\n* >=0.3.14 (DJ4.2, py3.11) includes locale\n\n\nInstallation\n============\n\n.. code-block:: bash\n\n pip install django-audit-fields\n\n\nAdd both ``django_audit_fields`` and ``django_revision`` to INSTALLED_APPS\n\n.. code-block:: python\n\n INSTALLED_APPS = [\n \"...\",\n \"django_revision.apps.AppConfig\",\n \"django_audit_fields.apps.AppConfig\",\n \"...\"]\n\nUsage\n=====\n\nAdd model fields to track creation and modification dates, users and more on save.\n\n\nDeclare your model using ``AuditModelMixin``\n\n.. code-block:: python\n\n from django_audit_fields.model_mixins import AuditModelMixin\n\n class MyModel(AuditModelMixin, models.Model):\n ...\n class Meta(AuditModelMixin.Meta):\n pass\n\nPreferably, use a UUID as primary key by declaring your model using ``AuditUuidModelMixin``\n\n.. code-block:: python\n\n from django_audit_fields.model_mixins import AuditUuidModelMixin\n\n class MyModel(AuditUuidModelMixin, models.Model):\n ...\n class Meta(AuditUuidModelMixin.Meta):\n pass\n\nThe model mixins ``AuditModelMixin`` and ``AuditUuidModelMixin``:\n\n* add audit fields (created, modified, user_created, user_modified, hostname_created, hostname_modified);\n\nThe model mixin ``AuditUuidModelMixin`` also\n\n* sets the id fields to a ``UUIDField`` instead of an integer;\n\n\nMost models require an audit trail. If so, add the ``HistoricalRecord`` model manager from ``django-simple-history``:\n\n.. code-block:: python\n\n from simple_history.models import HistoricalRecords\n\n class MyModel(AuditUuidModelMixin, models.Model):\n ...\n history = HistoricalRecords()\n\nNotes\n=====\n\nUser created and modified fields behave as follows:\n\n* created is only set on pre-save add\n* modified is always updated\n\n\n.. |pypi| image:: https://img.shields.io/pypi/v/django-audit-fields.svg\n :target: https://pypi.python.org/pypi/django-audit-fields\n\n.. |codecov| image:: https://codecov.io/gh/erikvw/django-audit-fields/branch/develop/graph/badge.svg\n :target: https://codecov.io/gh/erikvw/django-audit-fields\n\n.. |downloads| image:: https://pepy.tech/badge/django-audit-fields\n :target: https://pepy.tech/project/django-audit-fields\n\n.. |actions| image:: https://github.com/erikvw/django-audit-fields/actions/workflows/build.yml/badge.svg\n :target: https://github.com/erikvw/django-audit-fields/actions/workflows/build.yml\n",
"bugtrack_url": null,
"license": null,
"summary": "Add model fields to track creation and modification dates, users and more on save",
"version": "1.1.0",
"project_urls": null,
"split_keywords": [
"django",
" clinicedc",
" edc",
" clinical trials",
" research",
" data management",
" esource"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "fca078f089f75d153cf1104c2abc80b9b34415bc123a116da9c7440dd32766c9",
"md5": "eb4789f0a79ec47d83fce32a45404018",
"sha256": "972561a35db17c6e1b6327d99fe41d2f514a2d69cdd4a0264aca3cf11a71bdc2"
},
"downloads": -1,
"filename": "django_audit_fields-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "eb4789f0a79ec47d83fce32a45404018",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 24108,
"upload_time": "2025-07-21T20:30:56",
"upload_time_iso_8601": "2025-07-21T20:30:56.052024Z",
"url": "https://files.pythonhosted.org/packages/fc/a0/78f089f75d153cf1104c2abc80b9b34415bc123a116da9c7440dd32766c9/django_audit_fields-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "3a5695c1fb408b87977dc81f3aac9ec8e0b1d45830eda5551d2ffc822186cf97",
"md5": "e6e3ffcd8de1572f71251e1285a58989",
"sha256": "e01fc56ded65e8eefd45fb8d8584c8636f348d0858e197206c71b08c8892336e"
},
"downloads": -1,
"filename": "django_audit_fields-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "e6e3ffcd8de1572f71251e1285a58989",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 25925,
"upload_time": "2025-07-21T20:30:56",
"upload_time_iso_8601": "2025-07-21T20:30:56.978851Z",
"url": "https://files.pythonhosted.org/packages/3a/56/95c1fb408b87977dc81f3aac9ec8e0b1d45830eda5551d2ffc822186cf97/django_audit_fields-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-21 20:30:56",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "django-audit-fields"
}