skillfed

djangorestframework-guardian

django-guardian support for Django REST Framework

djangorestframework-guardian v0.4.0 160.5K downloads/30d#10,658 on PyPI163
Permissive license BSD-3-Clause AGING released

What it is and what it does

djangorestframework-guardian bridges django-guardian's object-level permission system into Django REST Framework's API layer. It provides two main tools: ObjectPermissionsFilter, which restricts querysets to only objects a user has permission to view, and ObjectPermissionsAssignmentMixin, which automatically assigns permissions to users or groups when objects are created or updated via serializers.

The package is designed for applications that need granular, per-object access control in REST APIs—where different users should see and modify different subsets of the same model. It requires django-guardian to be configured with its ObjectPermissionBackend and works alongside custom permission classes that map HTTP methods to specific permission names.

Use it for:

  • Multi-tenant SaaS APIs where each user should only see and modify their own data or shared resources.
  • Collaborative platforms where permissions are assigned per-object to users and groups dynamically.
  • Admin dashboards that expose REST endpoints with row-level security based on object permissions.
  • Workflows where creating a resource automatically grants specific permissions to the creator and designated groups.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Integrates django-guardian's object-level permissions into Django REST Framework, enabling fine-grained access control on API resources through filtering and automatic permission assignment.

Yes, if you are building a Django REST Framework API that requires object-level permissions beyond Django's standard model-level checks. The package is stable (Production/Stable status), has no known vulnerabilities, and low install friction. However, maintenance is infrequent (409 days since last release), so verify it works with your specific Django and djangorestframework versions before committing to it in a new project.

Install

djangorestframework-guardian on PyPI

pip

pip install djangorestframework-guardian

uv

uv add djangorestframework-guardian

poetry

poetry add djangorestframework-guardian

Installing djangorestframework-guardian

Before you install

Low friction: pure Python wheel with three straightforward dependencies (django, djangorestframework, django-guardian). Last release 2025-07-01; repository active and not archived, though 409 days since last release suggests maintenance is infrequent.

License in practice

BSD-3-Clause (permissive): you may use, modify, and distribute this package freely in commercial and open-source projects, provided you include the license notice.

Quickstart

pip install djangorestframework-guardian

from djangorestframework_guardian import filters

class MyViewSet:
    filter_backends = [filters.ObjectPermissionsFilter]

django-guardian and djangorestframework must be installed and configured in INSTALLED_APPS and AUTHENTICATION_BACKENDS before this package's filters will function.

Verify before relying

  • Whether ObjectPermissionsFilter works correctly with all Django REST Framework view types and pagination strategies.
  • Performance characteristics when filtering large querysets with many object-level permissions.
  • Compatibility with custom user models or non-standard permission backends.

Package facts

License BSD-3-Clause (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 3 — django, djangorestframework, django-guardian
Maintenance aging — 409 days since the last release
Last repo commit
First released
Downloads 160,532/month — #10,658 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: djangorestframework_guardian-0.4.0-py3-none-any.whl

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Intended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13

Tags

django rest framework object permissionsdjango-guardian api integrationrest api per-object access controldjango rest framework permission filteringobject-level permissions rest api
object-level-permissionsaccess-control

More Dynamic Content packages