Giter Site home page Giter Site logo

django-object-logger's Introduction

========================================
Django Object Log 
========================================

This app provides the ability to log user actions on model instances. Action 
types can be defined by app developers, and can reference multiple objects. 
Each action type defines it's own template used for rendering output of the 
message. It allows verbose messages specific to the action that occurred.

Object Log includes shortcuts both for adding entries and building views to 
display them.


Installation
----------------------------------------

There are several ways to install Object Log.

Object Log ships a standard distutils setup.py. A classic invocation
to install from setup.py might be::

 $ python setup.py install

You may need to add sudo in order to install to the system Python.

::

 $ sudo python setup.py install

We also have Object Log on PyPI, so it can be installed using pip.
(easy_install also works, but we do not recommend easy_install. Just use pip.)

::

 $ pip install django-object-log

If you are installing Object Log directly into a Django app, and want
to distribute Object Log with your app, simply copy the
object_log folder into your Django project.

Configuring Your Django Project
----------------------------------------

1) Add "object_log" to INSTALLED_APPS
2) Run ./manage.py syncdb
3) Add object_log.urls to urls if you wish to add views for displaying logs

Using Object Log
----------------------------------------

First, register some action types.  This can be done at any time but should
ideally be done once in models.py.  LogActions require both a key and a
template used to render that Action type.

>>> from object_log.models import LogAction
>>> LogAction.objects.register('MY_ACTION', 'path/to/my/template.html')

Now, that LogAction type can be used whenever that action occurs

>>> from object_log.models import LogItem
>>> log = LogItem.objects.log_action
>>> log('MY_ACTION', user, some_object)
>>> log('EDIT', user, some_object)
>>> log('DELETE', user, some_object)

Arbitrary data can also be included with each log entry by including a 
dict  It is available in the LogAction template as {{data}}.  This is
useful for caching information to reduce related queries when rendering
logs

>>> log('MY_ACTION', user, {'my_obj':str(obj1})

The data dict can be automatically populated from objects using a cache
function registered with the LogAction.  The cache function recieves the user, 
objects, and any data passed to log_Action().  It should return a dict.  This 
data overwrites manual data, you must merge it manually if you want to use both.

>>> def cache(user, obj1, obj2, obj3, data):
>>>    return dict(obj_str=str(obj1))
>>>
>>> LogAction.objects.register('MY_ACTION', 'path/to/my/template.html', cache)

log_action can then be used as normal.

>>> log('MY_ACTION', user, some_object)


See the wiki for more details:
http://code.osuosl.org/projects/django-object-log/wiki

Authors
-------

Object Log was implemented at the Oregon State University Open Source Lab 
(OSUOSL).  The primary author was Peter Krenesky.

django-object-logger's People

Contributors

doomer avatar

Watchers

 avatar  avatar  avatar

django-object-logger's Issues

Fix urls.py for django 1.6.X and 1.7

Hello,

I've found some error using your library with Django 1.6/1.7.

Source: urls.py

django.conf.urls.defaults

has been removed in Django 1.6.X+ and it can be fixed by changing the import to:

from django.conf.urls

Cheers

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.