A simple Django utlitity to allow tracking created/updated metadata of Django model records. When mixed in to your models, this tool will update created at/by information for new records as well as updated at/by inoformation when the record is updated using django signals.
- Django 1.11+
- Python 3.6+
-
Add to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [ ... 'blame', ]
-
Enable middleware to track the current request user:
MIDDLEWARE = [ ... 'blame.middleware.RequestMiddleware', ]
-
In your models:
from blame.models import BlameInfo class MyModel(BlameInfo): ...
-
Run
python manage.py migrate
to create the necessary models.
This app comes equiped with an optional mixin to resolve created_by
/updated_by
fields to just graphene.String
typed values. To enable this feature, add the
following mixin to your graphql types:
from graphene_django import DjangoObjectType
from blame.type import BlameInfo
class MyModelType(BlameInfo, DjangoObjectType):
...
It is highly encouraged you run the tests using the included docker stack.
-
Clone the application:
> git clone https://github.com/CodeBiosys/django-blame > cd django-blame
-
Provision a new Docker machine called
django-blame
:> docker-machine create -d virtualbox django-blame > eval $(docker-machine env django-blame) > docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS django-blame * virtualbox Running tcp://192.168.99.100:2376 v18.06.1-ce
Note the asterisk in the "ACTIVE" column.
-
Build the application stack and start the services:
> docker-compose build > docker-compose up -d
-
Run the tests
``` docker-compose run --rm app py.test ```