Registry / web-framework / django-role-permissions

django-role-permissions

JSON →
library3.2.0pypypiunverified

A Django app for role-based permissions. Version 3.2.0 is the latest; release cadence is irregular. It provides a simple way to manage user roles and their associated permissions.

pip install django-role-permissions
INSTALL
IMPORT
SIG · DJANGO-ROLE-PERMIS
D
django-role-permissions
web-frameworkpythonv3.2.0
Install
3.4s avg
Import
Disk
66MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.2.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 66.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.4s · import 0.000s · 67MB
66MB installed
● package 66MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Role
from rolepermissions.roles import Role
from rolepermissions.roles import Role
assign_role
from rolepermissions.roles import assign_role
get_user_roles
from rolepermissions.roles import get_user_roles

Assign a role to a user.

from rolepermissions.roles import assign_role from django.contrib.auth import get_user_model User = get_user_model() user = User.objects.create_user('john', 'john@example.com', 'password') assign_role(user, 'admin')
Debug
Known issues
gotchaRole classes must be defined in a file named `roles.py` in your Django app. The autodiscovery only looks for `roles.py`. If your file has a different name, roles won't be loaded.
fix
Create a `roles.py` file in your app directory and define roles there.
affects: all
breakingIn version 3.0, the `get_user_roles()` function was removed. Use `retrieve_role(user)` or check the role directly.
fix
Use `retrieve_role(user)` instead of `get_user_roles(user)`.
affects: >=3.0
deprecatedThe `add_role` function is deprecated in favor of `assign_role`. `assign_role` works identically.
fix
Replace `add_role(user, role_name)` with `assign_role(user, role_name)`.
affects: >=3.0
Upgrade
Version history
3.2.0latest on PyPI · released Jun 9, 2023
Audit
Dependencies
DjangorequiredRequired; integrates with Django models and auth.
Agent activity
24 hits · last 30 days
node
22
OpenAI (training)
1
Resources
django-role-permissions — pip install django-role-permissions · libregistry