A Django app for advanced logging capabilities
Project description
Django Tracker
Django Tracker is a middleware for Django that automatically audits and logs all model changes made through user requests. It records the user responsible, the fields changed, and other useful information for tracking data changes.
Installation
pip install django-tracker-unergy
Setup
- Add
'django_tracker'toINSTALLED_APPSin yoursettings.py:
INSTALLED_APPS = [
# ...
'django_tracker',
]
and add the middleware
MIDDLEWARE = [
# ...
'django_tracker.middleware.CurrentUserMiddleware'
]
- Run migrations:
python manage.py makemigrations
python manage.py migrate django_tracker
Usage
Auditable Decorator
from django_tracker.decorators import auditable
@auditable(
tracked_fields=['field1', 'field2'],
exclude_fiels=["created_at", "updated_at"]
audit_creates=True,
audit_updates=True,
audit_deletes=True,
level=AuditLevel.MEDIUM
)
class MyModel(models.Model):
field1 = models.CharField(max_length=100)
field2 = models.IntegerField()
# And the control attrb
Querying Audit Logs
You can view audit logs in the Django admin or directly from the model:
from django_tracker.models import AuditLog
# Get changes for a specific object
logs = AuditLog.objects.filter(
content_type__model='mymodel',
object_id=obj_id
)
# Get changes by user
logs = AuditLog.objects.filter(username='username')
License
MIT License. See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_tracker_unergy-1.2.5.tar.gz.
File metadata
- Download URL: django_tracker_unergy-1.2.5.tar.gz
- Upload date:
- Size: 16.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22b08a45efc8998e8df2d6ba20b538d9933f197ed86f46c4b25f69243bdcbd74
|
|
| MD5 |
afc39166d65353f825bffcfda1160406
|
|
| BLAKE2b-256 |
c77dbe7348d3400b3ff0b3be582044666990660296e8febc91b38bb411acde5d
|
File details
Details for the file django_tracker_unergy-1.2.5-py3-none-any.whl.
File metadata
- Download URL: django_tracker_unergy-1.2.5-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3dbbfe6ca2b3b0b627d691a02f55fca6bbfb5c6475a39751c19dfef7dc9f326b
|
|
| MD5 |
407381c285d0eb6064b5f83c1d9baaad
|
|
| BLAKE2b-256 |
10d78ba0b6617b5229cda4ce597f783282ac9c2b60dd174020704ec21289c43d
|