Provides an `AuditHistory` model field to store a chronological record of changes to a model (“audit history”) on the model. The historical record is stored in a designated JSON field, so no additional database tables are required.
Supports Django 1.11 (and possibly Django 2.x in the future) and PostgreSQL database backends.
## CI
[](https://travis-ci.org/nexto/django-model-audit-history)
## Usage
The basic principles are as follows:
1. To enable this for a model, you have to make these changes:
* add an `AuditHistoryField` named `history` to the model
* add the `AuditHistoryMixin` to the model class
* create ModelAdmin:
```
ModelAdmin(AuditHistoryAdminMixin, admin.ModelAdmin):
pass
```
* add your ModelAdmin to admin site `admin.site.register(model, ModelAdmin)`
2. Then, instead of calling regular `save()` on the model after changing it, call `save_with_audit_record()` instead (passing in some meta data you want saved alongside, e.g. the `event` that caused the change, the `user` triggering it and some `payload` usually the set of modified fields.
3. The history will appear in human-readable form in the admin.
That’s pretty much all there is to it.
## Testapp setup and first steps
1. Install Postgres locally (e.g. 10.x)
2. Create local database `audithistory`, owned by user `dev`
3. Create a virtualenv and activate: `virtualenv venv`, then `source venv/bin/activate`
4. Install dependencies into virtualenv: `pip install --requirement requirements.txt`
5. Run `manage.py migrate`
6. Run `manage.py createsuperuser`
7. Run `manage.py runserver`
8. Create new model on http://localhost:8000/admin/test_app/blogpost/
9. Edit model via http://localhost:8000/edit/1/
10. Reload admin page and inspect history record
## Run tests in local environment:
* Run `manage.py test` (Ensure that user dev has rights to db creation `alter user dev createdb;`)
Metadata
Release files for django-model-audit-history 1.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-model-audit-history-1.1.3.tar.gz | 6.1 kB | Without provenance | Details for django-model-audit-history-1.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_model_audit_history-1.1.3-py2-none-any.whl | Python 2 | none | any | Details for django_model_audit_history-1.1.3-py2-none-any.whl |
Total release size: 15.1 kB
Release files / django-model-audit-history-1.1.3.tar.gz
| Download URL | django-model-audit-history-1.1.3.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ed557cdedade5e23d8be75bc1970b0f58f5fbe5032d74da806dde32658d18dcd
|
|
BLAKE2b-256 checksum How to use checksums |
cc8ec61d94c12059d63605e045f120853e7a78e694f6c90f39b97268d326905a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.9
|
Release files / django_model_audit_history-1.1.3-py2-none-any.whl
| Download URL | django_model_audit_history-1.1.3-py2-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
f7b13ec2d878585ed74e1a21e0c2bdc778dd57aa5306b6822d366b6ceaba1381
|
|
BLAKE2b-256 checksum How to use checksums |
dcd2dff89addb0d8bfa85792b57d4f5c8e4a87c6da2f33276b00a91e4331e7a1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.9
|
Security for django-model-audit-history 1.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.