Skip to main content

Simple role-based user permissions for Django.

Project description

Add userroles do INSTALLED_APPS


Add the USER_ROLES setting


Define your Custom User model (optional)

AUTH_USER_MODEL = 'custom_user.EmailUser'

Add subroles for any of the roles defined in the USER_ROLES setting (optional)

    'staff_manager', 'business_manager'

Subroles can have sub-subroles and so on. But be careful not to repeat the names!

The role_required decorator provides similar behavior to Django’s login_required and permission_required decorators. If the user accessing the view does not have the required roles, they will be redirected to the login page.

from userroles.decorators import role_required

@role_required('manager', 'moderator')
def view(request):


from userroles.decorators import role_required
from userroles import roles

@role_required(roles.manager, roles.moderator)
def view(request):

If user has a subrole of the required role, it passes de user test as well!

Project details

Download files

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

Files for custom-user-roles, version 1.1.0
Filename, size File type Python version Upload date Hashes
Filename, size custom_user_roles-1.1.0-py2-none-any.whl (7.5 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size custom-user-roles-1.1.0.tar.gz (4.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page