django-guardian
Per object permissions for Django
What it is and what it does
django-guardian extends Django's built-in permission system to support per-object (row-level) access control. Instead of granting a user permission to change all instances of a model, you can grant permission to change a specific instance. It works by adding an extra authentication backend and database tables to track object-level grants for users and groups.
The package integrates directly into Django's permission checking—you use the same `has_perm()` method but pass an object instance as a third argument. It also provides admin integration through `GuardedModelAdmin` so you can manage object permissions in the Django admin panel. The library is widely used in production and supports modern Django versions (3.2–5.2) and Python 3.10+.
Use it for:
- Grant specific team members access to edit only their own projects or documents in a multi-tenant app.
- Implement row-level security where users can only view/modify records they own or have been assigned.
- Build admin panels where staff can manage permissions for individual model instances without code changes.
- Control access to sensitive objects (e.g., reports, files) on a per-user or per-group basis within a single model.
- Enforce organizational hierarchies where managers can only access records for their department or team.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
django-guardian adds per-object permission checks to Django, letting you grant or deny specific users and groups access to individual model instances rather than just model-wide permissions.
Yes. django-guardian is a mature, actively maintained library with no known vulnerabilities, low install friction, and permissive licensing. It solves a real problem—per-object permissions—that Django's built-in system does not address. Use it when you need fine-grained access control beyond model-level permissions.
Install
django-guardian on PyPI
pip
pip install django-guardianuv
uv add django-guardianpoetry
poetry add django-guardianInstalling django-guardian
Before you install
Low friction install with only django and typing_extensions as runtime dependencies. The package is actively maintained with a recent release (23 days old) and has been stable since its early releases, supporting Django 3.2 through 5.2 and Python 3.10–3.14.
License in practice
BSD-2-Clause is permissive, allowing commercial use, modification, and distribution with minimal restrictions—suitable for most projects.
Quickstart
pip install django-guardian
# In settings.py:
INSTALLED_APPS = (..., 'guardian')
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'guardian.backends.ObjectPermissionBackend',
)
# Then:
from guardian.shortcuts import assign_perm
assign_perm('change_group', user, obj=group_instance)
Requires running `python manage.py migrate` to create guardian database tables after installation.
Verify before relying
- Performance impact when checking permissions on large numbers of objects or users.
- Compatibility with custom authentication backends beyond those documented.
Package facts
| License | BSD-2-Clause (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — django, typing_extensions |
| Maintenance | actively maintained — 23 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,082,111/month — #4,395 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_guardian-3.3.3-py3-none-any.whl
Keywords: django, permissions, authorization, object, row, level
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
djangorestframework-guardianIntegrates django-guardian's object-level…
permissive · top 15,000 on PyPI
django-object-actionsAdds custom action buttons to Django admin…
permissive · top 5,000 on PyPI
dry-rest-permissionsDefines rules-based permissions for Django REST…
permissive · top 15,000 on PyPI
bridgekeeperBridgekeeper provides a permissions system for…
permissive · top 15,000 on PyPI
djangorestframework-role-filtersAdds role-based access control to Django REST…
permissive · top 5,000 on PyPI
django-prbacImplements parameterized role-based access…
unclear · top 15,000 on PyPI
django-read-onlyPrevents Django database write operations by…
permissive · top 15,000 on PyPI
django-hijackDjango Hijack lets administrators impersonate…
permissive · top 5,000 on PyPI
rulesrules provides object-level permission checking…
permissive · top 15,000 on PyPI
drf-access-policyDeclares access control rules for Django REST…
permissive · top 15,000 on PyPI