Skip to main content

django-bop

Django-bop provides Basic Object-level Permissions for django 1.2 and later. It is based on the django-advent article ‘Object Permissions’ by Florian Apolloner.

Although there are a few other permission backends I wanted a simple(r) backend that closely matches the existing django functionality.

Features

Django-bop provides several mechanisms to manage and check the permissions for objects:

  • bop.admin.ObjectAdmin

  • bop.forms.inline_permissions_form_factory

  • api.grant and api.revoke

  • bop.backends.ObjectBackend

  • ifhasperm templatetag

  • bop.managers.UserObjectManager

  • bop.managers.ObjectPermissionManager

Also of interest:

  • has_model_perms

Installation

Install it in your (virtual) environment:

$ pip install django-bop

If you haven’t already you should also install south:

$ pip install South

Add ‘bop’ (and south) to you INSTALLED_APPS in settings.py:

INSTALLED_APPS = (
  ...
  'south',
  'bop',
)

While in settings.py specify the AUTHENTICATION_BACKENDS:

AUTHENTICATION_BACKENDS = (
      'django.contrib.auth.backends.ModelBackend',
      'bop.backends.ObjectBackend',
)

If you, optionally, want to give permissions to anonymous users you should do the following:

  1. Add a user to contrib.auth.models.User to represent anonymous users (e.g. via the admin). Give it an appropriate name (anon / anonymous) so it easily recognized when assigning permissions.

  2. Add ANONYMOUS_USER_ID to settings.py:

    ANONYMOUS_USER_ID = 2

If, in addition – and again optionally – you want to support Model-permissions for anonymous users, you can add the AnonymousModelBackend:

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'bop.backends.AnonymousModelBackend',
    'bop.backends.ObjectBackend',
)

When all configuration is done, bring the database up to date:

$ ./manage.py migrate bop

Release files for django-bop 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-bop 0.3
File Size Uploaded
django-bop-0.3.tar.gz 13.8 kB Details

Release files / django-bop-0.3.tar.gz

Download URL django-bop-0.3.tar.gz
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a6f025f3dfd9ee0bf74dafdaa93a6ab10d96048f1c483e8fff91d43c1fe2b58b
BLAKE2b-256 checksum
How to use checksums
561b0522561cb958c5a92633043ba32ebf4bcd1cfced40d68e81de0e4ad7a9c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3 This release

1 release file

0.2

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page