Skip to main content

Django groups manager through django-mptt.

Project description

# Django groups manager

[![Build Status](]( [![Coverage Status](]( ![Version](

This application allows to create hierarchical groups by using [django-mptt]( tree structure.
It is also possible to synchronize the groups with Django's ``auth.models`` Group and User, in order to take advantage of permissions applications like [django-guardian](

## Documentation

Online documentation is available at

## Installation

Use pip to install ``django-groups-manager``:

pip install django-groups-manager

### Django Configuration

1. Add ``groups_manager`` into your ``INSTALLED_APPS``:


If you want to use permissions related features, add also ``django-guardian``.

2. Run syncdb:

python syncdb

3. To enable django ``auth.models`` synchronization, add to the settings module:


## Basic usage

The common case is to create a simple parent-son relation:

from groups_manager.models import Group, Member
fc_internazionale = Group.objects.create(name='F.C. Internazionale Milan')
staff = Group.objects.create(name='Staff', parent=fc_internazionale)
players = Group.objects.create(name='Players', parent=fc_internazionale)
thohir = Member.objects.create(first_name='Eric', last_name='Thohir')
palacio = Member.objects.create(first_name='Rodrigo', last_name='Palacio')

Per-object permissions handling is done by ``django-guardian``. The Group/Member relation can be used to assing objects:

from football.models import TeamBudget
small_budget = TeamBudget.objects.create(euros='1000')
thohir.assign_object(staff, small_budget)
thohir.has_perm('change_teambudget', small_budget) # True
palacio.has_perm('change_teambudget', small_budget) # False

Owner/Group members policies can be defined via ``PERMISSIONS`` setting, as a dictionary of ``GROUPS_MANAGER``, but can also be overwritten via ``custom_permissions`` ``kwarg``:

from football.models import Match
fc_barcelona = Group.objects.create(name='FC Barcelona')
friendly_match = Match.objects.create(home=fc_internazionale, away=fc_barcelona)
palacio.assign_match(players, friendly_match, custom_permissions={'group': ['play']})
thohir.has_perm('play_match', friendly_match) # False
palacio.has_perm('play_match', friendly_match) # True

For more complex cases, see documentation.

Project details

Download files

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

Source Distribution

django-groups-manager-0.2.0.tar.gz (28.5 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page