{"id":44757,"library":"django-prbac","title":"django-prbac","description":"Parameterized Role-Based Access Control for Django. Provides hierarchical roles with customizable parameters (e.g., plan limits), integrates with Django admin, and supports migrations. Current version: 1.1.2. Release cadence: infrequent, last updated in 2021.","status":"maintenance","version":"1.1.2","language":"python","source_language":"en","source_url":"https://github.com/dimagi/django-prbac","tags":["rbac","django","authorization","roles"],"install":[{"cmd":"pip install django-prbac","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency","package":"django","optional":false},{"reason":"Used for storing role parameter schemas","package":"jsonfield","optional":false},{"reason":"Used for Python 2/3 compatibility, but may be redundant with Python 3.9+","package":"six","optional":true}],"imports":[{"wrong":"from prbac.roles import PrbacRole","symbol":"PrbacRole","correct":"from django_prbac.roles import PrbacRole"}],"quickstart":{"code":"# settings.py\nINSTALLED_APPS = [\n    'django.contrib.contenttypes',\n    'django.contrib.auth',\n    'prbac',\n    # ... other apps\n]\n\n# Run migrations: python manage.py migrate prbac\n\n# Then in code:\nfrom prbac.roles import PrbacRole\nrole = PrbacRole('plan:pro')\n# Check permission\nuser.has_perm('prbac.access_role', obj=role)\n\n# Or use decorator\nfrom prbac.decorators import requires_privilege\n@requires_privilege('plan:pro')\ndef my_view(request):\n    return HttpResponse('ok')","lang":"python","description":"Minimal setup: add 'prbac' to INSTALLED_APPS, run migrations, then use PrbacRole and decorators."},"warnings":[{"fix":"Add a 'get_roles()' method to your user model that returns a list of PrbacRole objects.","message":"The 'requires_privilege' decorator checks against the request.user's roles, but the user model must have a 'get_roles()' method. If you have a custom user model, ensure it implements this method.","severity":"gotcha","affected_versions":"all"},{"fix":"Monkey-patch or fork to replace jsonfield with Django's JSONField. No official migration path provided.","message":"The 'jsonfield' dependency is deprecated and may cause compatibility issues with newer Django versions. Consider using Django's built-in JSONField.","severity":"deprecated","affected_versions":">=1.1.0"},{"fix":"Restart your Django app after role changes, or use the appropriate sync command for your backend.","message":"Roles are defined in data, not code. After changing role permissions via Django admin, you must run 'manage.py sync_couch_views' if using CouchDB backend, otherwise role changes are not effective until restart.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"search_vec":"'1.1.2':30 '2021':37 'access':8 'admin':24 'author':40 'base':7 'cadenc':32 'control':9 'current':28 'customiz':16 'django':2,11,23,39 'django-prbac':1 'e.g':18 'hierarch':13 'infrequ':33 'integr':21 'last':34 'limit':20 'migrat':27 'paramet':17 'parameter':4 'plan':19 'prbac':3 'provid':12 'rbac':38 'releas':31 'role':6,14,41 'role-bas':5 'support':26 'updat':35 'version':29","created_at":"2026-06-07T12:51:41.175740+00:00","updated_at":"2026-06-07T12:51:41.175740+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nModuleNotFoundError: No module named 'django_prbac.roles'"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/dimagi/django-prbac","github":"https://github.com/dimagi/django-prbac","docs":null,"changelog":null,"pypi":null,"npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["security"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}