# 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
```bash
pip install django-tracker-unergy
```
## Setup
1. Add `'django_tracker'` to `INSTALLED_APPS` in your `settings.py`:
```python
INSTALLED_APPS = [
# ...
'django_tracker',
]
```
and add the middleware
```python
MIDDLEWARE = [
# ...
'django_tracker.middleware.CurrentUserMiddleware'
]
```
2. Run migrations:
```bash
python manage.py makemigrations
python manage.py migrate django_tracker
```
## Usage
### Auditable Decorator
```python
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:
```python
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.
Raw data
{
"_id": null,
"home_page": null,
"name": "django-tracker-unergy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10.13",
"maintainer_email": null,
"keywords": "django, logging, audit, tracking",
"author": null,
"author_email": "Dmoreno2903 <diegomoreno2903@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/d6/8c/35da5c33cdd75b54180e8a9dd71180ec8ff804dc3b9b2a4d8fa0b69589b0/django_tracker_unergy-1.2.2.tar.gz",
"platform": null,
"description": "# Django Tracker\n\nDjango 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.\n\n## Installation\n\n```bash\npip install django-tracker-unergy\n```\n\n## Setup\n\n1. Add `'django_tracker'` to `INSTALLED_APPS` in your `settings.py`:\n\n```python\nINSTALLED_APPS = [\n # ...\n 'django_tracker',\n]\n```\nand add the middleware\n```python\nMIDDLEWARE = [\n # ...\n 'django_tracker.middleware.CurrentUserMiddleware'\n]\n```\n\n2. Run migrations:\n\n```bash\npython manage.py makemigrations\npython manage.py migrate django_tracker\n```\n\n## Usage\n\n### Auditable Decorator\n\n```python\nfrom django_tracker.decorators import auditable\n\n@auditable(\n tracked_fields=['field1', 'field2'],\n exclude_fiels=[\"created_at\", \"updated_at\"]\n audit_creates=True,\n audit_updates=True,\n audit_deletes=True,\n level=AuditLevel.MEDIUM\n)\nclass MyModel(models.Model):\n field1 = models.CharField(max_length=100)\n field2 = models.IntegerField()\n # And the control attrb\n```\n\n### Querying Audit Logs\n\nYou can view audit logs in the Django admin or directly from the model:\n\n```python\nfrom django_tracker.models import AuditLog\n\n# Get changes for a specific object\nlogs = AuditLog.objects.filter(\n content_type__model='mymodel',\n object_id=obj_id\n)\n\n# Get changes by user\nlogs = AuditLog.objects.filter(username='username')\n```\n\n## License\n\nMIT License. See LICENSE file for details.\n",
"bugtrack_url": null,
"license": null,
"summary": "A Django app for advanced logging capabilities",
"version": "1.2.2",
"project_urls": {
"Repository": "https://gitlab.com/unergy-dev/origination/django-tracker.git"
},
"split_keywords": [
"django",
" logging",
" audit",
" tracking"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "4754c97202394b3eea1f9e4a8e0373d262e63b59b97097ba93c9f0eb0989f39c",
"md5": "7eeeaaf6ba6feabe59a9865cddaee334",
"sha256": "3dbd95c2af986156ccf2e1929d0cb8e5c6be26e93c2596c6a39577d42c5fbccb"
},
"downloads": -1,
"filename": "django_tracker_unergy-1.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7eeeaaf6ba6feabe59a9865cddaee334",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10.13",
"size": 23082,
"upload_time": "2025-09-08T20:00:19",
"upload_time_iso_8601": "2025-09-08T20:00:19.901215Z",
"url": "https://files.pythonhosted.org/packages/47/54/c97202394b3eea1f9e4a8e0373d262e63b59b97097ba93c9f0eb0989f39c/django_tracker_unergy-1.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d68c35da5c33cdd75b54180e8a9dd71180ec8ff804dc3b9b2a4d8fa0b69589b0",
"md5": "f1afc8f12f1426139260d859a00895ec",
"sha256": "cd3cc357a2c289e88892c83b4bc561e177629ab5f50deef7478926fb77eb8daf"
},
"downloads": -1,
"filename": "django_tracker_unergy-1.2.2.tar.gz",
"has_sig": false,
"md5_digest": "f1afc8f12f1426139260d859a00895ec",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10.13",
"size": 16749,
"upload_time": "2025-09-08T20:00:20",
"upload_time_iso_8601": "2025-09-08T20:00:20.771867Z",
"url": "https://files.pythonhosted.org/packages/d6/8c/35da5c33cdd75b54180e8a9dd71180ec8ff804dc3b9b2a4d8fa0b69589b0/django_tracker_unergy-1.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-08 20:00:20",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "unergy-dev",
"gitlab_project": "origination",
"lcname": "django-tracker-unergy"
}