Django Delta Logger
A django app that provides a model class that records changes in django models.
Installation
Get the Package
pip install django_delta_logger
Update the Django Settings
Add django_delta_logger to the INSTALLED_APPS list.
INSTALLED_APPS=[
# ...
'django_delta_logger',
# ...
]
Make sure JSON_ENCODER is set in the django settings. A reasonable default is provided and is directly importable into an existing settings file.
from django_delta_logger.settings import JSON_ENCODER
Usage
Django_delta_logger's primary API is a context manager:
from django_delta_logger.delta_logger import DeltaLogger
with DeltaLogger(SomeDjangoModel, SomeOtherDjangoModel):
foo = SomeDjangoModel(name='foo')
foo.save()
Log Results
Access the history of a model instance from the DeltaEvent model.
from django_delta_logger.models import DeltaEvent
instance = SomeModel.objects.get(pk=1)
events = DeltaEvent.objects.get_for_instance(instance).all()
for event in events:
print(event.event_time, event.event_type, event.event_data)
from django_delta_logger.models import DeltaEvent
events = DeltaEvent.objects.get_for_model(SomeDjangoModel).all()
for event in events:
print(event.event_time, event.event_type, event.event_data)
The Risks of Concurrency
Tracking the dirtyness of a model instance field is performant but can lead to inaccurate log data when one
model instance is edited in multiple threads/processes/servers.
When data accuracy in a concurrent environment is worth the performance cost of a fetch-before-write:
from django_delta_logger.delta_logger import DeltaLogger
with DeltaLogger(SomeDjangoModel, concurrent=True):
foo = SomeDjangoModel(name='foo')
foo.save()
Test Suite
python setup.py test
License
This software is published under the MIT License. See the LICENSE file
for details.
Metadata
Release files for django-delta-logger 0.1.1
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_delta_logger-0.1.1.tar.gz | 5.0 kB | Without provenance | Details for django_delta_logger-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_delta_logger-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for django_delta_logger-0.1.1-py3-none-any.whl |
Total release size: 13.1 kB
Release files / django_delta_logger-0.1.1.tar.gz
| Download URL | django_delta_logger-0.1.1.tar.gz |
|---|---|
| Size | 5.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
45cfedc680a9fecdbf2c71293c25635ddc27ca461bbcb08c174959bdb78cf89a
|
|
BLAKE2b-256 checksum How to use checksums |
a4f1d650e8de597f5fe0f5034fb7ae89951e2c38c850c34a04a64112dadc2799
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.5.2
|
Release files / django_delta_logger-0.1.1-py3-none-any.whl
| Download URL | django_delta_logger-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce14c750ce50cd141b0dc22403835e7f3f7b5f6d51ab91fc066586df203b33cb
|
|
BLAKE2b-256 checksum How to use checksums |
55cd616eca825d492de8b8a7a202c390241b515aea626da0ec941350e914a619
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.5.2
|
Security for django-delta-logger 0.1.1
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.