Track changes to django models
Project description
Simple django app for tracking db changes executed through orm. (Only tested on python3 and django-1.8.1)
Usage
Once installed (see ``Installation`` below), every change to tracked model will be recorded whenever ``save`` or ``delete`` is called.
To include usefull information about circumstances of the changes use
model.save(request=request)
or
model.save(track_token=token)
Same goes for model.delete(), where request is just django HttpRequest instance, and token is result of tracked_model.control.create_track_token(request) call.
This will store djagno user making changes along with ip, host, user agent, request path, request method, referer and request timestamp.
To access model’s history, call it’s tracked_model_history method
model.tracked_model_history()
Model instance can be created from History instance by calling materialize
model = SomeModel.objects.create(attr='initial') model.attr = 'change 1' model.save() model.attr = 'change 2' model.save() model_initial_state = model.tracked_history().first().materialize()
Installation
$ pip install django-tracked-model
Add tracked_model to INSTALLED_APPS in settings.
Synch db
$ python manage.py syncdb
Mark model as trackable
from django.db import models from tracked_model.control import TrackedModelMixin as Tracked class MyModel(Tracked, models.Model): spam = models.IntegerField() egg = models.TextField()
Tests & mods
If for some weird reason you want to hack around, clone repo and install stuff from dev-reqs.txt
$ pip install -r dev-reqs.txt
There is a Makefile with some handy shortcuts e.g.
$ make test
$ make qa
Poke around Makefile for details
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
Hashes for django-tracked-model-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92714239733cb8575e093ce6684d5d081c53fa195534b6e668d81ccd96c20c0a |
|
MD5 | b68413d1f63c1a91e8947dd8fa19589f |
|
BLAKE2b-256 | ef3c4f5b9c6e39bd1db57c9ebf95876822f67088ff8660dfb6852974644968e6 |