Django model version mixin
Project description
Model version
Model version allows to track changes to Django model instances. Each time
an instance is updated, its version
number is incremented and old values are
copied to a new record, that represents previous version of the current instance.
Installation
To install the library use pip:
pip install model_version
Usage
To enable model versioning ModelVersion
should be used as one of base classes
a model inherits from:
from model_version import ModelVersion
class MyModel(ModelVersion):
...
This will add three new fields to the model:
version
- integer number starting from0
(default version start number)version_id
-uuid4
that represents different versions of the same recordversion_created_at
- timestamp record
Create and apply migrations with the new fields:
python ./manage.py makemigration
python ./manage.py migrate
Limitations
- Doesn't work with bulk operations.
- Requires additional DB query on save.
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
model_version-0.1.0.tar.gz
(14.7 kB
view hashes)
Built Distribution
Close
Hashes for model_version-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64ea55f94da6cae853add56bd48b86cde115246cf1f684d09bf575d49fb087f0 |
|
MD5 | 0db63af180c613e895b11c537ffd16c2 |
|
BLAKE2b-256 | b4616167a61a74844276c1798e5a5197c6ffc7b22f40e71783915fa418e2980b |