• Python >= 3.5
  • Django >= 2

First of all, install the latest build with pip:

pip install django-groups-manager
# and, in case you want per-object permissions related features
pip install django-guardian

or the repository master version for latest updates:

pip install

Add groups_manager to installed apps:

    # 'guardian', # add as well to use permissions related features

Run syncdb or migrate:

python migrate

If you want to use standard templates, add groups_manager’s urls from

urlpatterns = ('',
    # ...
    url(r'^groups-manager/', include('groups_manager.urls', namespace='groups_manager')),
    # ...

Supported templates are based on bootstrap3, and django-bootstrap3 application is required:

pip install django-bootstrap3

If you don’t want to use bootstrap3, you can override forms (see Templates documentation).

Basic usage

A simple use case for this application is the tracking of customers groups. Each organization can have more than one division, and a member can be in more than one:

from groups_manager.models import Group, GroupType, Member

# Create group types (optional)
organization = models.GroupType.objects.create(label='Organization')
division = models.GroupType.objects.create(label='Division')

# Organization A has 'commercials' and 'managers'
org_a = Group.objects.create(name='Org A, Inc.', group_type=organization)
org_a_commercials = Group.objects.create(name='Commercials', group_type=division, parent=org_a)
org_a_managers = Group.objects.create(name='Managers', group_type=division, parent=org_a)
# Tina is a commercial
tina = Member.objects.create(first_name='Tina', last_name='Rossi')
# Jack is a manager
jack = Member.objects.create(first_name='Jack', last_name='Black')

#Assign objects to members or groups
product = Product.objects.create(name='Fancy product')  # Product has 'sell_product' permission
tina.assign_object(org_a_commercials, product)
tina.has_perm('sell_product', product)  # True
jack.has_perm('sell_product', product)  # False
budget = Budget.objects.create(name='Facilities', amount=5000)  #  has 'use_budget' permission
tina.has_perm('use_budget', budget)  # False
jack.has_perm('use_budget', budget)  # True