{"id":26914,"library":"drf-access-policy","title":"DRF Access Policy","description":"Declarative access policies/permissions modeled after AWS' IAM policies for Django REST Framework. Current version 1.5.0, with active development and periodic releases.","status":"active","version":"1.5.0","language":"python","source_language":"en","source_url":"https://github.com/rsinger86/drf-access-policy","tags":["django","django-rest-framework","authorization","access-control","iam-policy"],"install":[{"cmd":"pip install drf-access-policy","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Required for Django REST Framework integration.","package":"django","optional":false},{"reason":"The library extends DRF's permission classes.","package":"djangorestframework","optional":false}],"imports":[{"note":"The import path uses 'rest_framework_access_policy', not 'drf_access_policy'.","wrong":"from drf_access_policy import AccessPolicy","symbol":"AccessPolicy","correct":"from rest_framework_access_policy import AccessPolicy"},{"note":"","wrong":"","symbol":"FieldAccessMixin","correct":"from rest_framework_access_policy import FieldAccessMixin"},{"note":"","wrong":"","symbol":"PermittedPkRelatedField","correct":"from rest_framework_access_policy import PermittedPkRelatedField"},{"note":"","wrong":"","symbol":"PermittedSlugRelatedField","correct":"from rest_framework_access_policy import PermittedSlugRelatedField"},{"note":"","wrong":"","symbol":"Statement","correct":"from rest_framework_access_policy import Statement"}],"quickstart":{"code":"from rest_framework.views import APIView\nfrom rest_framework_access_policy import AccessPolicy\n\nclass MyView(APIView):\n    access_policy = {\n        \"statements\": [\n            {\n                \"action\": [\"list\"],\n                \"principal\": \"*\",\n                \"effect\": \"allow\",\n            },\n        ]\n    }","lang":"python","description":"Define an access policy as a dictionary on the view. The policy controls actions allowed for principals."},"warnings":[{"fix":"Replace 'condition' elements with 'condition_expression' and use Python-style boolean operators.","message":"Version 1.0.0 changed condition evaluation: 'condition' no longer supports multiple methods with boolean logic. Use 'condition_expression' instead.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use 'from rest_framework_access_policy import AccessPolicy'.","message":"Import path is 'rest_framework_access_policy', not 'drf_access_policy'. Many users mistakenly use the latter.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade your Python environment to 3.6 or newer.","message":"Python 3.5 support dropped in version 1.5.0. Use Python 3.6+.","severity":"deprecated","affected_versions":">=1.5.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Replace 'import drf_access_policy' with 'import rest_framework_access_policy' or use 'from rest_framework_access_policy import AccessPolicy'.","cause":"Incorrect import path; the correct package is 'rest_framework_access_policy'.","error":"ModuleNotFoundError: No module named 'drf_access_policy'"},{"fix":"Rename 'condition' to 'condition_expression' and adjust boolean expressions.","cause":"Using 'condition' with boolean logic in version 1.0.0+; the syntax changed.","error":"KeyError: 'condition_expression'"},{"fix":"Run 'pip install drf-access-policy' and check your Python environment.","cause":"Package not installed or installed under different name. Possibly installed 'drf-access-policy' but import path is correct.","error":"ImportError: cannot import name 'AccessPolicy' from 'rest_framework_access_policy'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}