Django Permafrost
Django Permafrost is an extension to Django's permissions framework. Its goal is to allow developers to expose selected permissions to client users so they can create and manage custom user roles inside a tenant or site context.
It adds:
- A View Mixin that supports user permissions based on different HTTP method types (GET, POST, PUT, etc) for extra granular control.
- A View Mixin that captures into Django's logging setup any failed permission checks.
- An app that supports client user definable roles and permissions. This uses Django's underlying permission system and controls which permissions are exposed to users.
- Developers can define required permissions for each role category and optional permissions that can be selected by the client.
For example, a SaaS platform may allow client administrators to manage other users in their account. They may want one employee to manage email lists but not invite users, while another employee can do both. Permafrost lets the developer define the permission boundaries and lets the client assemble roles inside those boundaries.
Supported versions
This release targets:
- Python 3.11+
- Django 5.2 through Django 6.1
Django 5.1 and older are no longer supported.
Installation
To install, use pip:
python -m pip install django-permafrost
To add it to your project, add it to the list of installed apps in your settings.py:
INSTALLED_APPS = [
...
"django.contrib.contenttypes",
"django.contrib.auth",
"django.contrib.sites",
"permafrost",
...
]
Then migrate:
python manage.py migrate
Setup
The goal of Django Permafrost is to allow clients to create their own Permafrost roles under developer-defined categories with developer-defined required and optional permissions.
An example developer-defined category looks like this:
from django.utils.translation import gettext_lazy as _
PERMAFROST_CATEGORIES = {
"user": {
"label": _("User"),
"access_level": 1,
"optional": [
{
"label": _("Can Add Users to Role"),
"permission": ("add_user_to_role", "permafrost", "permafrostrole"),
},
],
"required": [
{
"label": _("Can add Role"),
"permission": ("add_permafrostrole", "permafrost", "permafrostrole"),
},
],
},
}
This would be added to your Django settings.py file (or, at least, included into).
In the above, we define the User category, give it the localizable label of "User", and provide two permissions in Django's natural key format. Primary keys can differ between environments, so natural keys are safer for permission configuration.
There is also an access_level setting to help make sorting access levels more easily.
Context model
Permafrost roles are scoped to a context object. By default, that context is Django's Site model, which preserves the original subdomain/site-per-client behavior:
PERMAFROST_CONTEXT_MODEL = "sites.Site"
PERMAFROST_CONTEXT_REQUEST_ATTR = "site"
Projects that use a different tenant model can set the context model once at the beginning of the project, similar to how a custom user model is configured:
PERMAFROST_CONTEXT_MODEL = "accounts.Organization"
PERMAFROST_CONTEXT_REQUEST_ATTR = "organization"
Permafrost expects the current context object to be available on the request using PERMAFROST_CONTEXT_REQUEST_ATTR. For example, middleware might attach request.organization. If no request context is available, the configured context model must provide a manager method named get_current(). The built-in Site default uses Site.objects.get_current().
Internally, Permafrost stores the context through Django's content type framework, but each project should configure exactly one context model for the lifetime of that project.
For more detail, see the files in docs/modules/, especially installation.md and models.md.
Recommendations
It is recommended that you update your code to use PermafrostRole's built-in functions to add users and permissions. They add an extra level of checking to make sure the permissions passed in are allowed by the PERMAFROST_CATEGORIES configuration.
For example, permissions on a Group:
group.permissions.set([permission_list])
group.permissions.add(permission, permission, ...)
group.permissions.remove(permission, permission, ...)
group.permissions.clear()
Can be replaced with:
PermafrostRole.permissions_set([permission_list])
PermafrostRole.permissions_add(permission, permission, ...)
PermafrostRole.permissions_remove(permission, permission, ...)
PermafrostRole.permissions_clear()
Convenience tools
There is a tool to help the developer list out the permissions available in the format permafrost expects.
> ./manage permlist
using the command will produce a list like this
> ./manage.py permlist
Permlist formatted for your PermafrostRoles configuration
{'label':_('Can add email address'), 'permission': ('add_emailaddress', 'account', 'emailaddress')},
{'label':_('Can change email address'), 'permission': ('change_emailaddress', 'account', 'emailaddress')},
{'label':_('Can delete email address'), 'permission': ('delete_emailaddress', 'account', 'emailaddress')},
...
Each line can be copied into the PERMAFROST_CATEGORIES config in the correct format.
Metadata
Release files for django-permafrost 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_permafrost-0.4.1.tar.gz | 42.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_permafrost-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 95.1 kB
Release files / django_permafrost-0.4.1.tar.gz
| Download URL | django_permafrost-0.4.1.tar.gz |
|---|---|
| Size | 42.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39d923625871b9c8d0f892963a79a758066af808ac5bf7160cabbab7ae3b937c
|
|
BLAKE2b-256 checksum How to use checksums |
f9c1623d142dbc4a5a4300823b4d62aff881b6c4509dbd59f5e37f31f84ab99e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency logRelease files / django_permafrost-0.4.1-py3-none-any.whl
| Download URL | django_permafrost-0.4.1-py3-none-any.whl |
|---|---|
| Size | 53.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc4ee3fa532da096c1425a409b3e1ce28be4fbf1145c8c3b98b5855fc0be3d66
|
|
BLAKE2b-256 checksum How to use checksums |
f5c36181f212e0561d5cb0ec474aa48440f595bd6ffac33e0e18c88a68605b33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.
Transparency log