Store model fields history
Project description
django-fields-history
A Django app that track history changes in model fields.
Important note: currently only one implementation of FieldsHistory
is supported and it's with django.contrib.postgres.fields.JSONField
which is JSONB
under the hood. So only postgresql as database is supported
Similar projects:
Main difference that those libraries keep track of changes, and this library tracks the history change.
Simple explanation:
from field_history.trackers import FieldsHistoryTracker
class SimpleModel(models.Model):
field = models.CharField(max_length=50)
field_history = FieldsHistoryTracker(fields=['field'])
obj = SimpleModel.objects.create(field='value')
assert not obj.get_field_history()
obj.field = "new_value"
obj.save()
assert obj.get_field_history()
assert obj.get_field_history()[0].value == "value"
QuickStart
Install django-fields-history
:
pip install django-fields-history
Add fields_history.postgres
to INSTALLED_APPS
(currently only
postgres implementation is supported):
INSTALLED_APPS = [
# rest of apps
"fields_history.postgres",
]
And add trackers to your models and specify fields to track:
from field_history.trackers import FieldsHistoryTracker
class YourModel(models.Model):
...
history_tracker = FieldsHistoryTracker(fields=["field1", "field2"])
And you are done.
Implementation
Every change of your fields field changes be tracked in
fields_history.models.FieldsHistory
in:
fields_history.postgres
-JSONB
postgres field
One object per save if tracked fields has been changed.
Credits
Basically this project is implemented based on django-field-history which itself used django-model-utils.
Project details
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
File details
Details for the file django-fields-history-0.1.3.tar.gz
.
File metadata
- Download URL: django-fields-history-0.1.3.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.10 Darwin/21.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4fe367b1e6b23cf08ce85dcc88f854c69c5f7db6818edb7cb6bf286865958a9 |
|
MD5 | 9566bf9a4d66edec644b282ce7e0167f |
|
BLAKE2b-256 | 850b6d89790c396d6e3bf58a73a7c0bb5c4960734afb674c0d71e646bb1b78ed |
File details
Details for the file django_fields_history-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: django_fields_history-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.10 Darwin/21.3.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55c03965e35c15b0ec187f100bf76eb1cff7342a074d8269f4918d6a8d43c6e2 |
|
MD5 | 48fd58fd11e3cad0ac17a4fd148e4850 |
|
BLAKE2b-256 | f3cf303528b63d455139e234cb5d1d67842d90cc14524787a06785c66b397c7f |