Metadata-Version: 2.1
Name: model-version
Version: 0.1.0
Summary: Django model version mixin
Home-page: https://github.com/aleosd/model-version
License: GPL-3.0-only
Keywords: django,model,version
Author: Alex
Author-email: osdalex@gmail.com
Requires-Python: >=3.8,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: Django
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: Django (>=4.0,<5.0)
Project-URL: Documentation, https://github.com/aleosd/model-version
Project-URL: Repository, https://github.com/aleosd/model-version.git
Description-Content-Type: text/markdown

# 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:

```shell
pip install model_version
```

## Usage

To enable model versioning `ModelVersion` should be used as one of base classes
a model inherits from:

```python
from model_version import ModelVersion


class MyModel(ModelVersion):
    ...
```

This will add three new fields to the model:

* `version` - integer number starting from `0` (default version start number)
* `version_id` - `uuid4` that represents different versions of the same record
* `version_created_at` - timestamp record

Create and apply migrations with the new fields:

```shell
python ./manage.py makemigration
python ./manage.py migrate
```

## Limitations

1. Doesn't work with bulk operations.
2. Requires additional DB query on save.

