{"id":35312294,"url":"https://github.com/kindlycat/permission-manager-drf","last_synced_at":"2026-01-16T16:47:23.676Z","repository":{"id":236835031,"uuid":"793256033","full_name":"kindlycat/permission-manager-drf","owner":"kindlycat","description":"Declarative per action/object permissions","archived":false,"fork":false,"pushed_at":"2026-01-15T10:59:56.000Z","size":156,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-15T15:52:02.496Z","etag":null,"topics":["django","django-rest-framework","drf","permissions"],"latest_commit_sha":null,"homepage":"https://permission-manager-drf.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kindlycat.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-04-28T20:59:29.000Z","updated_at":"2026-01-15T10:52:17.000Z","dependencies_parsed_at":null,"dependency_job_id":"6a148994-8acb-4bdd-961e-2acfd68f3aaf","html_url":"https://github.com/kindlycat/permission-manager-drf","commit_stats":null,"previous_names":["kindlycat/permission-manager-drf"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/kindlycat/permission-manager-drf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kindlycat%2Fpermission-manager-drf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kindlycat%2Fpermission-manager-drf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kindlycat%2Fpermission-manager-drf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kindlycat%2Fpermission-manager-drf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kindlycat","download_url":"https://codeload.github.com/kindlycat/permission-manager-drf/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kindlycat%2Fpermission-manager-drf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28480081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","django-rest-framework","drf","permissions"],"created_at":"2025-12-30T17:48:23.069Z","updated_at":"2026-01-16T16:47:23.660Z","avatar_url":"https://github.com/kindlycat.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Permission Manager for django rest framework\n\n![PyPI - Version](https://img.shields.io/pypi/v/permission-manager-drf?logo=python)\n![example workflow](https://github.com/kindlycat/permission-manager-drf/actions/workflows/tests.yml/badge.svg)\n[![codecov](https://codecov.io/gh/kindlycat/permission-manager-drf/graph/badge.svg?token=5XAFJZS6A8)](https://codecov.io/gh/kindlycat/permission-manager-drf)\n\nUse [permission_manager](https://github.com/kindlycat/permission-manager) for \ndjango rest framework.\n\nFull documentation on [read the docs](https://permission-manager-drf.readthedocs.io/).\n\n## Install\n\n```bash\npip install permission-manager-drf\n```\n\n## Example\n```python\nfrom django.db import models\nfrom rest_framework.permissions import IsAuthenticated\nfrom rest_framework.viewsets import ModelViewSet\nfrom rest_framework.decorators import action\n\nfrom permission_manager_drf import DRFPermissionManager, ManagerPermission\nfrom permission_manager import PermissionResult\n\n\n# Define permission manager\nclass SomeModelPermissionManager(DRFPermissionManager):\n    def has_create_permission(self) -\u003e bool:\n        return self.user.is_staff\n\n    def has_update_permission(self) -\u003e bool:\n        return self.user.is_staff\n\n    def has_delete_permission(self) -\u003e bool:\n        return self.user.is_staff\n\n    def has_view_permission(self) -\u003e bool:\n        return True\n\n    def has_list_permission(self) -\u003e bool:\n        return True\n\n    def has_custom_permission(self) -\u003e bool:\n        return PermissionResult(\n            message=\"You can't do it\",\n            value=self.user.is_staff,\n        )\n\n\n# Define model with permission manager attribute\nclass SomeModel(models.Model):\n    permission_manager = SomeModelPermissionManager\n    ...\n\n\n# ViewSet\nclass TestModelViewSet(ModelViewSet):\n    permission_classes = [IsAuthenticated, ManagerPermission]\n    ...\n\n    @action(detail=True)\n    def custom(self, request, **kwargs):\n        ...\n```\nThat's all. Now every drf action will be checked by the permission manager.\n\nAlso, you can use the serializer field for retrieve permissions you need.\n\n```python\nfrom permission_manager_drf import PermissionField\nfrom rest_framework.serializers import ModelSerializer\n\nclass SomeModelSerializer(ModelSerializer):\n    permissions = PermissionField(actions=('view', 'custom'),)\n    ...\n\n\"\"\"\nExample output:\n{\n    ...,\n    'permissions': {\n        'view': {\n            'allow': True,\n            'messages': None,\n        },\n        'custom': {\n            'allow': False,\n            'messages': [\"You can't do it\"],\n        },\n    }\n}\n\"\"\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkindlycat%2Fpermission-manager-drf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkindlycat%2Fpermission-manager-drf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkindlycat%2Fpermission-manager-drf/lists"}