Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Django row level object sharing app.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 sharing
Octocat-spinner-32 AUTHORS.rst
Octocat-spinner-32 CHANGELOG.rst
Octocat-spinner-32 LICENSE
Octocat-spinner-32 MANIFEST.in
Octocat-spinner-32 README.rst
Octocat-spinner-32 setup.py
README.rst

Django Sharing

Django row level sharing app limiting content access by user in Django admin.

Features

  1. Provides admin view, change and delete permissions, restricting content access and limiting available actions per user.
  2. Filters ForeignKey fields by view permissions.
  3. Filters ManyToManyField fields by view permissions.
  4. Automatically enables sharing on all admin classes (optional).

Installation

  1. Install or add django-sharing to your python path.
  2. Add 'sharing' to the project's INSTALLED_APPS setting.
  3. Add 'sharing.backends.SharingBackend' to the project's AUTHENTICATION_BACKENDS setting.

Usage

In order for django-sharing to limit content access your various admin classes need to include the ShareAdminMixin class. For example:

# admin.py
from django.contrib import admin
from sharing.admin import ShareAdminMixin

class ArticleAdmin(ShareAdminMixin, admin.ModelAdmin):
    pass

admin.site.register(Article, ArticleAdmin)

It is crucial for ShareAdminMixin to be the first ancestor class in the admin class' definition.

Alternatively you can automatically enable sharing for all models registered with the admin site. django-sharing includes an admin_mixin_share method which will apply the ShareAdminMixin class to all models registered with the admin site. Call the method after admin.autodiscover() in urls.py:

# urls.py
from django.conf.urls.defaults import *
from django.contrib import admin

import sharing

admin.autodiscover()
sharing.admin_mixin_share()

urlpatterns = patterns('',
    (r'^admin/', include(admin.site.urls)),
)

Once the ShareAdminMixin class has been applied your admin change views should include Group and User share inlines and restrict content appropriately.

Something went wrong with that request. Please try again.