# Django Model History Tracker
Django Model History Tracker is a utility that tracks changes to model instances and saves the history of updates. This can be helpful for auditing purposes or for generating reports about changes over time.
## Features
- Track creation, update, and deletion of model instances
- Store historical data in a separate `History` model
- Easy integration with existing Django models using a mixin
## Installation
1. Install the package using pip:
pip install django-model-history-tracker
2. Add `'django_model_history_tracker'` to your `INSTALLED_APPS` in `settings.py`:
```python
INSTALLED_APPS = [
...
'django_model_history_tracker',
...
]
python manage.py migrate
## Usage
To use Django Model History Tracker, simply inherit the HistoryTrackerMixin in any model you want to track:
from django.db import models
from django_model_history_tracker.mixins import HistoryTrackerMixin
class ExampleModel(HistoryTrackerMixin, models.Model):
field1 = models.CharField(max_length=100)
field2 = models.IntegerField()
That's it! Your model will now automatically track changes and store them in the History model.
Accessing History
You can access the history of a tracked model instance using the generic relation:
history = example_model_instance.history_set.all()
Each history entry will have the following fields:
action: The action that occurred ('create', 'update', or 'delete')
timestamp: The timestamp of when the action occurred
changes: A JSON field containing the changes made to the instance
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests on the GitHub repository.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/yourusername/django_model_history_tracker",
"name": "django-model-history-tracker",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "django model history tracker auditing",
"author": "Your Name",
"author_email": "your.email@example.com",
"download_url": "https://files.pythonhosted.org/packages/d3/8f/b7cf359de3a9aa0064140222517a18db33295ee9f4a2ea4ebb47646be65f/django-model-history-tracker-0.2.tar.gz",
"platform": null,
"description": "# Django Model History Tracker\n\nDjango Model History Tracker is a utility that tracks changes to model instances and saves the history of updates. This can be helpful for auditing purposes or for generating reports about changes over time.\n\n## Features\n\n- Track creation, update, and deletion of model instances\n- Store historical data in a separate `History` model\n- Easy integration with existing Django models using a mixin\n\n## Installation\n\n1. Install the package using pip:\n\npip install django-model-history-tracker\n\n2. Add `'django_model_history_tracker'` to your `INSTALLED_APPS` in `settings.py`:\n\n```python\nINSTALLED_APPS = [\n ...\n 'django_model_history_tracker',\n ...\n]\n\npython manage.py migrate\n\n\n ## Usage\n\nTo use Django Model History Tracker, simply inherit the HistoryTrackerMixin in any model you want to track:\n\nfrom django.db import models\nfrom django_model_history_tracker.mixins import HistoryTrackerMixin\n\nclass ExampleModel(HistoryTrackerMixin, models.Model):\n field1 = models.CharField(max_length=100)\n field2 = models.IntegerField()\n\nThat's it! Your model will now automatically track changes and store them in the History model.\n\n\nAccessing History\n\nYou can access the history of a tracked model instance using the generic relation:\n\nhistory = example_model_instance.history_set.all()\n\nEach history entry will have the following fields:\n\n action: The action that occurred ('create', 'update', or 'delete')\n timestamp: The timestamp of when the action occurred\n changes: A JSON field containing the changes made to the instance\n\n\nContributing\n\nContributions are welcome! Please feel free to submit issues or pull requests on the GitHub repository.\n\n\nLicense\n\nThis project is licensed under the MIT License. See the LICENSE file for details.\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A Django utility to track changes to model instances and save the history of updates.",
"version": "0.2",
"split_keywords": [
"django",
"model",
"history",
"tracker",
"auditing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d3aad4555aa7a5398adac1fabd4752108efc52544330f9235254f936b4ed53e9",
"md5": "b88933e0852b9f86ba6275fcf13ff0cf",
"sha256": "718de663232430daa87d6599815add1829929208c9f1118d0ff13fb6ae3bf380"
},
"downloads": -1,
"filename": "django_model_history_tracker-0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b88933e0852b9f86ba6275fcf13ff0cf",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 4558,
"upload_time": "2023-04-01T13:03:21",
"upload_time_iso_8601": "2023-04-01T13:03:21.700990Z",
"url": "https://files.pythonhosted.org/packages/d3/aa/d4555aa7a5398adac1fabd4752108efc52544330f9235254f936b4ed53e9/django_model_history_tracker-0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d38fb7cf359de3a9aa0064140222517a18db33295ee9f4a2ea4ebb47646be65f",
"md5": "5c98d637162f8081869b3d67b09004ef",
"sha256": "22090f3e40ac2ca1834fc79b3ce60ca3ba715b68fa12b47f100525fa5f8fcb9a"
},
"downloads": -1,
"filename": "django-model-history-tracker-0.2.tar.gz",
"has_sig": false,
"md5_digest": "5c98d637162f8081869b3d67b09004ef",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 3354,
"upload_time": "2023-04-01T13:03:25",
"upload_time_iso_8601": "2023-04-01T13:03:25.663861Z",
"url": "https://files.pythonhosted.org/packages/d3/8f/b7cf359de3a9aa0064140222517a18db33295ee9f4a2ea4ebb47646be65f/django-model-history-tracker-0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-04-01 13:03:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "yourusername",
"github_project": "django_model_history_tracker",
"lcname": "django-model-history-tracker"
}