Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install django-userel

How to install django-userel

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install django-userel
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.0.3 Available View build log
0.0.1 Available View build log
Windows (64-bit)
0.0.3 Available View build log
0.0.1 Available View build log
Mac OS X (10.5+)
0.0.3 Available View build log
0.0.1 Available View build log
Linux (32-bit)
0.0.3 Available View build log
0.0.1 Available View build log
Linux (64-bit)
0.0.3 Available View build log
0.0.1 Available View build log
 
Author
License
MIT
Dependencies
Lastest release
version 0.0.3 on May 23rd, 2012

Userel is a extend ForeignKey for User model. It add auto_now and auto_now_add for setting current access user automatically.

Install

sudo pip install django-userel

or:

sudo pip install git+https://github.com/lambdalisue/django-userel.git#egg=django-userel

How to Use

  1. Append 'userel' to INSTALLED_APPS
  2. Add 'userel.middlewares.UserelDefaultBackendMiddleware' to your MIDDLEWARE_CLASSES if you use default userel backend

Example mini blog app

models.py:

from django.db import models
from django.contrib.auth.models import User

from userel.fields import UserelField

class Entry(models.Model):
        PUB_STATES = (
                ('public', 'public entry'),
                ('protected', 'login required'),
                ('private', 'secret entry'),
        )
        pub_state = models.CharField('publish status', choices=PUB_STATES)
        title = models.CharField('title', max_length=140)
        body = models.TextField('body')

created_by = UserelField('created by', related_name='entries_create', auto_now_add=True)
updated_by = UserelField('updated_by', related_name='entries_update', auto_now=True)

Settings

USEREL_BACKEND
Class or string path of backend. the backend is used to determine user when object is created/updated.

Backend

The default backend use thread_locals storategy to get current request in signal call.

If you want to change the strategy or whatever, create your own backend.

A backend is a class which have get_user method to determine current user.

UserelDefaultBackend
Default backend. This backend return None when no request found or AnonymousUser create/update object.
UserelSystemUserBackend

System user backend. This backend return system user when no request found or AnonymousUser create/update object.

system user is determined with get_system_user method and default is User.objects.get(pk=1)

Subscribe to package updates

Last updated May 23rd, 2012

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.