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-JSONBpostgres 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
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_fields_history-0.1.7.tar.gz.
File metadata
- Download URL: django_fields_history-0.1.7.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.5 Darwin/22.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7128a070366a0783257e813ea637a6e75bf793ad026127e34ac40f8608c70138
|
|
| MD5 |
83b92c99e9b346948a6515ece4b6debf
|
|
| BLAKE2b-256 |
fbef7dd490b18beaab7f88482013a6a10b8914f751b3611fd5b20442d86bee83
|
File details
Details for the file django_fields_history-0.1.7-py3-none-any.whl.
File metadata
- Download URL: django_fields_history-0.1.7-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.2 CPython/3.11.5 Darwin/22.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31d25bbd1d33c1202e4ac438520e94dead8f3653af15c18b8015c56c049dce95
|
|
| MD5 |
95f12670d8c3ea077f53cf863fbccc3f
|
|
| BLAKE2b-256 |
fac43d0bf9e901c8966560859797fabb8f069d768e59053f8c9e01a55e58f91d
|