Class based Django permissions for Django models.
Project description
Simple class based permissions.
Installation
Install using pip:
pip install django-perm
In settings.py:
# Add to INSTALLED_APPS 'perm', # Add to AUTHENTICATION_BACKENDS 'perm.backends.ModelPermissionBackend',
In your main urls.py, at the end add:
# Load django-perm urlpatterns += patterns('', url('^/perm/', include('perm.urls')))
Usage
In your Django app, create a file permissions.py. Its content might look like this:
from perm.decorators import permissions_for from perm.permissions import ModelPermissions from .models import Foo @permissions_for(Foo) class FooPermissions(ModelPermissions): def has_perm_wiggle(self): # Let's ask the Foo object return self.obj.user_can_wiggle(self.user) def get_queryset_perm_change(self): # Foo objects can be changed by their owners return Foo.objects.filter(user=self.user)
Questions
Do you have a question about django-perm? Please ask it on StackOverflow.com so others can help out and/or learn. Tag your question django-perm if possible.
Bugs and requests
If you have found a bug or a request for additional functionality, please use the issue tracker on GitHub.
About
django-perm is written by Dylan Verheul (dylan@dyve.net).
License
You can use this under Apache 2.0. See LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-perm-2.4.1.tar.gz
.
File metadata
- Download URL: django-perm-2.4.1.tar.gz
- Upload date:
- Size: 8.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b6b6cc9ef68214ca20ac5f9225b5322c083c7a693f912260bbde754606a1968 |
|
MD5 | 5959b90c665f28bc03576370153f8daa |
|
BLAKE2b-256 | 9a983eb70618845b8161fc708e9e4256ae80404dd71e7a49e8937477d66aba02 |