Django app which handles ORM objects' versions.
Project description
ognajDv0.1.3
Django app which handles ORM objects' versions.
Description
ognajD is Django-compactible application which handles versionning for ORM models. Main feature is for ognjaD to be a "plug-in" Django application, thus capable to work with "little-to-no" configuring and changes to Django project.
Features
ognajd stores objects' versions in own table, relied on contenttypes
application.
ognajD @ v0.1.3 can:
- catch object's save / update signals
- store snapshot of object in DB with:
- timestamp
- serialized version
- hash
- object version may be serialized (currently, only JSON) as:
- diff with previous version (by default)
- raw dumps
Usage example
sample-project
is a showcase django project, based on famous
polls
application.
You can reference to it for usage cases, examples, testing.You must never deploy sample_project
in
production due to exposed SECRET_KEY
.
Getting Started
Dependencies
Python packages
django~=3.2.7
might work on lesser versions, not testedjsondiff~=1.3.0
might work on lesser versions, not tested
Django applications
contenttypes
Installing
Using Python Package Index
-
make sure to use latest
pip
:python3 -m pip install --upgrade pip
-
install
django-ognajd
:python3 -m pip install django-ognajd
OR download package from releases
-
download release asset (
.tar.gz
or.whl
) -
make sure to use latest
pip
:python3 -m pip install --upgrade pip
-
install
django-ognajd
from file:python3 -m pip install /path/to/downloaded/asset.tar.gz # or .whl
OR clone from repository
-
clone project:
git clone \ --depth=1 \ --branch=master \ git@github.com:omelched/django-ognajd.git \ </path/to/downloads>
-
move
/django-ognajd/ognajd
solely to folder containing django appsmv </path/to/downloads>/django-ognajd/ognajd \ </path/to/django/project/apps>
-
remove leftovers
rm -rf </path/to/downloads>/django-ognajd
Configuring
Installing application
Add ognajd
to INSTALLED_APPS
in your Django project settings.py
.
If you installed package the third way make sure that </path/to/django/project/apps>
is added to PYTHONPATH
. If you not sure add code below in your Django project manage.py
before calling main()
:
sys.path.append('</path/to/django/project/apps>')
Registering models
To register your model as eligible for versioning add attribute-class VersioningMeta
to model class definition.
For typing, linters, autocompletion tyou can inherit from ognajd.models.VersioningMeta
.
Then set preferred options.
e.g:
# .../your_app/models.py
from django.db import models
from ognajd.models import VersioningMeta
class Question(models.Model):
class VersioningMeta(VersioningMeta):
store_diff = False
... # fields' definitions
VersioningMeta
options
Name | Description | Type | Default |
---|---|---|---|
enabled |
True : if model will be versioned False : if will not |
bool |
True |
store_diff |
True : model's history will be stored as diffs False : as dumps |
bool |
True |
save_empty_changes |
True : if empty changes will be registered False : if will not |
bool |
True |
Authors
@omelched (Denis Omelchenko)
Contributors
Changelist
ognajD version history and changelist available at releases page.
License
This project is licensed under the GNU APGLv3 License - see the LICENSE file for details.
Acknowledgments
Inspiration, code snippets, etc.
- polls showcase app code from sample-django
- index incrementer at model save from
tinfoilboy
Project details
Release history Release notifications | RSS feed
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-ognajd-0.1.3.tar.gz
.
File metadata
- Download URL: django-ognajd-0.1.3.tar.gz
- Upload date:
- Size: 19.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1eb219d6aa223de8c3ca68cb96d416d16a2760a243a7c0e09988294f8aa4979b |
|
MD5 | 8b94e368e17a9e91a9865c13cbc1274e |
|
BLAKE2b-256 | aa061300a481d39f955d375b8b932f46a4c13801c5f2e643d8397957764be73e |
Provenance
File details
Details for the file django_ognajd-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: django_ognajd-0.1.3-py3-none-any.whl
- Upload date:
- Size: 26.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38e2adb7ed25c23a20640cb35df6561487772478751688485fde0e066cb0c0c8 |
|
MD5 | 638f4ace21bcf162dca8f408168207ae |
|
BLAKE2b-256 | a79e22df7a99e35d6e8b8397baccf271b7a19f4ec90d7b5b23c643984f6eeda8 |