Skip to main content
Help us improve Python packaging – donate today!

Logging django models changes.

Project Description

Django simple log

https://travis-ci.org/kindlycat/django-simple-log.svg?branch=master https://coveralls.io/repos/github/kindlycat/django-simple-log/badge.svg?branch=master

Logging model changes on every create/update/delete.

TL;DR

Install using pip:

$ pip install django-simple-log

Add to installed apps:

INSTALLED_APPS = (
    ...
    'simple_log',
    ...
)

Add middleware for detecting user:

MIDDLEWARE = [
    ...
    'simple_log.middleware.ThreadLocalMiddleware',
    ...
]

For django 1.8:

$ pip install django-jsonfield django-transaction-hooks
DATABASES = {
    'default': {
        'ENGINE': 'transaction_hooks.backends.postgresql_psycopg2',
        ...
    }
}

Migrate:

$ python manage.py migrate

Add to any __init__.py:

import simple_log

# For track all registered applications, including third-party
simple_log.register()
# Or for concrete model
simple_log.register(Model)
# Or multiple models
simple_log.register(Model, AnotherModel)
# For define log model
simple_log.register(Model, AnotherModel, log_model=CustomLogModel)

Disable logging

For temporary disable logging:

from simple_log.utils import disable_logging

with disable_logging():
    # create/update/delete objects

Commands

To view which models is tracking:

$ python manage.py view_tracking_models

With option -f you can view which fields is tracking for every model.

Settings

SIMPLE_LOG_MODEL_LIST

Default: ()

If set, than simple_log.register() register only models in the list.

If you use simple_log.register(Model), this setting will be ignored.

SIMPLE_LOG_EXCLUDE_MODEL_LIST

Default: ('admin.LogEntry', 'migrations.Migration', 'sessions.Session', 'contenttypes.ContentType', 'captcha.CaptchaStore')

If set, than simple_log.register() register every model except in the list.

If you use simple_log.register(Model) or SIMPLE_LOG_MODEL_LIST, this setting will be ignored.

SIMPLE_LOG_EXCLUDE_FIELD_LIST

Default: ('id', 'last_login', 'password', 'created_at', 'updated_at')

List of field names which not track.

If you need to define which fields to track for concrete model, you can add one of the properties to model: simple_log_fields = ('id',) or simple_log_exclude_fields = ('password',).

SIMPLE_LOG_ANONYMOUS_REPR

Default: 'Anonymous'

User representation that write to log, if anonymous user changes model.

SIMPLE_LOG_NONE_USER_REPR

Default: 'System'

User representation that write to log, if user not detected (If middleware not working or if model changes from task or console).

SIMPLE_LOG_MODEL

Default: 'simple_log.SimpleLog'

Model for writing logs. If you want to define your own model, you can inheritance from simple_log.SimpleLogAbstract and change this setting.

SIMPLE_LOG_MODEL_SERIALIZER

Default: 'simple_log.models.ModelSerializer'

Class for serializing model fields to json.

SIMPLE_LOG_GET_CURRENT_REQUEST

Default: 'simple_log.utils.get_current_request_default'

Function that return current request. Rewrite this setting if you already have middleware for storing current request.

SIMPLE_LOG_OLD_INSTANCE_ATTR_NAME

Default: '_old_instance'

Attribute’s name for storing old instance of logging object.

Release history Release notifications

History Node

0.1.30

History Node

0.1.29

History Node

0.1.28

History Node

0.1.27

History Node

0.1.26

History Node

0.1.25

History Node

0.1.24

History Node

0.1.23

History Node

0.1.22

History Node

0.1.21

History Node

0.1.20

History Node

0.1.19

History Node

0.1.18

History Node

0.1.17

History Node

0.1.16

History Node

0.1.15

History Node

0.1.14

History Node

0.1.13

History Node

0.1.12

History Node

0.1.11

History Node

0.1.10

History Node

0.1.9

History Node

0.1.8

History Node

0.1.7

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.0

This version
History Node

0.0.8

History Node

0.0.6

History Node

0.0.5

History Node

0.0.4

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
django_simple_log-0.0.8-py2.py3-none-any.whl (17.6 kB) Copy SHA256 hash SHA256 Wheel py2.py3 May 20, 2017
django-simple-log-0.0.8.tar.gz (10.3 kB) Copy SHA256 hash SHA256 Source None May 20, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page