Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A simple class based permission backend for django

Project Description

Really simple permission backend for django

Class based, No database

Inspired by django-permission

Tested with Django 1.10 - python 3.5


The app autodiscover module in your project’s apps.

This modules should register PermissionLogic based class.

When calling django’s has_perm method, it will run the corresponding method name in your PermissionLogic class.

See usage section below for comprehensive example.


  # ...
  'simple_perms',  # Add simple_perms app to your INSTALLED_APPS
  # ...

    'simple_perms.PermissionBackend',  # Add permission backend before django's one


from simple_perms import register, PermissionLogic

class ProjectLogic(PermissionLogic):

    def add_project(self, user, project, perm):
        return True

    def change_project(self, user, project, perm):
        return user.is_admin() or project.owner == user

    delete_project = change_project

    def default_permission(self, user, project, perm):
      # Optional, default to global default permission, which default to False
      return user.is_admin()

register('project_app', ProjectLogic)
user1.has_perm('project_app.add_project')  # True
user1.has_perm('project_app.change_project', user1_project)  # True
user1.has_perm('project_app.delete_project', user1_project)  # True
user2.has_perm('project_app.change_project', user1_project)  # False
admin.has_perm('project_app.change_project', user1_project)  # True

Default permission

If a checked permission doesn’t exists in registered PermissionLogic based classe, the backend will run the default_permission method of this class. If no default_permission defined, it default to the global default permission which default to False.

Change global default permission



def custom_global_default_permission(user, obj, perm):
    return user.is_admin()

global_default_permission and default_permission have the same arguments as others permissions : (user, obj, perm)

Change autodiscovered module name

simple_perms autodiscover modules in every django’s apps. You can change the module name to autodiscover using the SIMPLE_PERMS_MODULE_NAME setting :


Run tests


Release History

This version
History Node


History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(4.7 kB) Copy SHA256 Hash SHA256
Source None Nov 28, 2016

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting