{"id":23597,"library":"django-role-permissions","title":"django-role-permissions","description":"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.","status":"active","version":"3.2.0","language":"python","source_language":"en","source_url":"http://github.com/vintasoftware/django-role-permissions","tags":["django","roles","permissions","authorization"],"install":[{"cmd":"pip install django-role-permissions","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required; integrates with Django models and auth.","package":"Django","optional":false}],"imports":[{"note":"Module is `roles`, not `role`.","wrong":"from rolepermissions.role import Role","symbol":"Role","correct":"from rolepermissions.roles import Role"}],"quickstart":{"code":"from rolepermissions.roles import assign_role\nfrom django.contrib.auth import get_user_model\nUser = get_user_model()\nuser = User.objects.create_user('john', 'john@example.com', 'password')\nassign_role(user, 'admin')","lang":"python","description":"Assign a role to a user."},"warnings":[{"fix":"Create a `roles.py` file in your app directory and define roles there.","message":"Role 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `retrieve_role(user)` instead of `get_user_roles(user)`.","message":"In version 3.0, the `get_user_roles()` function was removed. Use `retrieve_role(user)` or check the role directly.","severity":"breaking","affected_versions":">=3.0"},{"fix":"Replace `add_role(user, role_name)` with `assign_role(user, role_name)`.","message":"The `add_role` function is deprecated in favor of `assign_role`. `assign_role` works identically.","severity":"deprecated","affected_versions":">=3.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Move role assignments into Django signal handlers or inside functions that are called after app setup (e.g., in `apps.py` ready() method).","cause":"Using role-related imports or functions at module level before Django is fully configured.","error":"django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet."},{"fix":"Run `pip install django-role-permissions` and add `'rolepermissions'` to INSTALLED_APPS in settings.py.","cause":"Missing import or not installed or not included in INSTALLED_APPS.","error":"No module named 'rolepermissions'"},{"fix":"Upgrade to latest version: `pip install --upgrade django-role-permissions` or use `add_role` if using older version.","cause":"Outdated version (before 3.0) where assign_role was added.","error":"AttributeError: module 'rolepermissions.roles' has no attribute 'assign_role'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}