Skip to main content

django-minosse

Role-based access control for Django, without the extra database tables.

django-minosse lets you define roles as Python classes, sync them to Django's built-in Group model, and protect views with decorators or mixins — all on top of the django.contrib.auth machinery you already have.


Requirements

  • Python 3.12+
  • Django 5.0+

Installation

pip install django-minosse

or with uv:

uv add django-minosse

Add "minosse" to INSTALLED_APPS, alongside the standard auth and contenttypes apps that are already present in every Django project:

INSTALLED_APPS = [
    ...
    "django.contrib.auth",
    "django.contrib.contenttypes",
    "minosse",
    ...
]

Run python manage.py migrate at least once so the auth tables exist before calling sync() or get_group().

Quick start

1. Define roles

# myapp/roles.py
from minosse.roles import AbstractRole, RoleRegistry

registry = RoleRegistry()

@registry.register
class EditorRole(AbstractRole):
    group_name = "Editors"
    available_permissions = {
        "can_publish": True,
        "can_edit": True,
        "can_delete": False,
    }

@registry.register
class ViewerRole(AbstractRole):
    group_name = "Viewers"
    available_permissions = {
        "can_view_reports": True,
    }

2. Sync roles to the database

from myapp.roles import registry

registry.sync()   # call from a management command or AppConfig.ready()

3. Protect views

Function-based views:

from django.contrib.auth.decorators import login_required
from minosse.decorator import role_required, permission_required
from .roles import EditorRole

@login_required
@role_required(EditorRole)
def editor_dashboard(request):
    ...

@login_required
@permission_required("auth.can_publish")
def publish_article(request, pk):
    ...

Class-based views:

from django.views.generic import TemplateView
from minosse.mixin import RoleRequiredMixin, PermissionRequiredMixin
from .roles import EditorRole

class EditorDashboardView(RoleRequiredMixin, TemplateView):
    required_role_class = EditorRole
    template_name = "editor/dashboard.html"

class PublishView(PermissionRequiredMixin, TemplateView):
    required_permission_codename = "auth.can_publish"
    template_name = "editor/publish.html"

4. Manage role membership

# Assign / remove
EditorRole.add_user_to_role(user)
EditorRole.remove_user_from_role(user)

# Check
if EditorRole.user_has_role(user):
    ...

Features

  • Define roles as Python classes with declarative permission sets
  • Sync roles and permissions to Django's Group / Permission models
  • Protect function-based views with @role_required and @permission_required
  • Protect class-based views with RoleRequiredMixin and PermissionRequiredMixin
  • Check roles and permissions in templates with |can and |is filters
  • Register roles centrally via RoleRegistry for bulk sync

Documentation

Full documentation is available in the docs/ directory and can be served locally:

make docs-serve

License

MIT

Release files for django-minosse 1.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-minosse 1.1.3
File Size Uploaded
django_minosse-1.1.3.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-minosse 1.1.3
File Interpreter ABI Platform
django_minosse-1.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 16.1 kB

Release files / django_minosse-1.1.3.tar.gz

Download URL django_minosse-1.1.3.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5cff769daa30b31ea26ff467393b6ab78144240c03bbf3b8dc9bd3489022d5dc
BLAKE2b-256 checksum
How to use checksums
f06499f5df8a9ffa1e325375fefb8d8ae36ffe1cc6eff28bd3bd13212d82c7a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 20, 2026.

Transparency log

Release files / django_minosse-1.1.3-py3-none-any.whl

Download URL django_minosse-1.1.3-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
929d7f4b548a6cdd64ea0b0f29d7bc8b56777b681e133761f662faad3d4d87be
BLAKE2b-256 checksum
How to use checksums
30ec6137f1d0b1a978f6720e8a7a09b3f7caefd1339d3db47aefbc8be0440f8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jun 20, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.3 This release

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page