Add user-managed, multi-user groups to your Django project. Use django-organizations whether your site needs organizations that function like social groups or multi-user account objects to provide account and subscription functionality beyond the individual user.
django.contrib.authand does not add or require additional user or authentication functionality
First add the application to your Python path. The easiest way is to use
$ pip install django-organizations
You should install by downloading the source and running::
python setup.py install
Make sure you have
django.contrib.auth installed, and add the
application to your
INSTALLED_APPS = ( ... 'django.contrib.auth', 'organizations', )
Then ensure that your project URL conf is updated. You should hook in the main application URL conf as well as your chosen invitation backend URLs:
from organizations.backends import invitation_backend urlpatterns = patterns('', ... url(r'^accounts/', include('organizations.urls')), url(r'^invitations/', include(invitation_backend().get_urls())), )
You can specify a different invitation backend in your project settings, and
invitation_backend function will provide the URLs defined by that
ORGS_INVITATION_BACKEND = 'myapp.backends.MyInvitationBackend'
For most use cases it should be sufficient to include the app views directly using the default URL conf file. You can customize their functionality or access controls by extending the base views.
There are three models:
throughmodel for the ManyToMany relationship between the
Organizationmodel and the
Usermodel. It stores additional information about the user specific to the organization and provides a convenient link for organization ownership.
OrganizationUsermodel. This allows
Userobjects to own multiple organizations and makes it easy to enforce ownership from within the organization's membership.
The underlying organizations API is simple:
>>> chris = User.objects.get(username="chris") >>> soundgarden = create_organization(chris, "Soundgarden") >>> soundgarden.is_user(chris) True >>> soundgarden.is_admin(chris) True >>> soundgarden.owner.organization_user <OrganizationUser: Chris Cornell> >>> soundgarden.owner.organization_user.user >>> <User: chris> >>> audioslave = create_organization(chris, "Audioslave") >>> tom = User.objects.get(username="tom") >>> audioslave.add_user(tom, is_admin=True) <OrganizationUser: Tom Morello>
Each organization can have only one owner, however a site user can be a member
of multiple organizations, or own multiple organizations. The OrganizationUser
model servers as an intermediary between the
Organization and the
Development is on-going. To-do items have been moved to the wiki for the time being.
The basic functionality should not need much extending. Current dev priorities for me and contributors should include:
Please use the project's issues tracker to report bugs. Thanks!
django-organizations should be backend agnostic:
Anyone is free to use or modify this software under ther terms of the BSD license.