Skip to main content

🚀 django_resaas

Full-stack framework for building secure, multi-tenant business applications with Django and Quasar — this is the Django backend; quasar_resaas is the frontend.

PyPI Python Django License: Commercial Status


If you've ever built a SaaS API in Django, you know the drill: multi-tenancy, per-group and per-branch permissions, soft delete, file uploads, PDF generation, i18n, usage limits… all of it again, project after project.

django_resaas solves that part once and for all. It's a framework built on top of Django + DRF that gives any application a production-ready foundation: multi-tenancy, RBAC, smart CRUD, dynamic search, per-client feature modules and entitlements (features and usage limits) — so your team can focus on what actually matters: the business.

pip install django_resaas

Table of contents


🎯 Why it exists

"Building SaaS shouldn't be repetitive."

Every multi-tenant SaaS app ends up needing the same set of building blocks. django_resaas ships them ready-made, tested, and consistent with each other:

Without django_resaas With django_resaas
Multi-tenancy hand-rolled on every project BaseModel already ships entity + branch
Permissions checked manually in every view Automatic RBAC via Entity + Branch + Group
CRUD written from scratch for every resource BaseAPIView gives full CRUD in ~5 lines
Destructive delete with no way back Native soft delete + restore + hard delete
Custom search per endpoint Automatic dynamic search (?search=)
"All or nothing" modules Per-client module activation (App + EntityApp)
Translations scattered across the code Central i18n system (DB + lang/ files)

✨ Features

  • 🔐 RBAC — permissions by User + Group + context (Entity/Branch)
  • 🏢 Native multi-tenancy — isolation by Entity and Branch
  • ⚡ Automatic CRUD — BaseAPIView with pagination, ordering, filtering and permissions built in
  • 🔎 Dynamic search — automatic search across text fields and relations
  • ♻️ Soft delete — delete() / restore() / hard_delete() + dedicated managers
  • 🧩 Per-client modules — toggle features on/off per entity without a deploy (App + EntityApp)
  • 🎚️ Entitlements — features, capacities (quantitative limits) and modules per installation/tenant, behind a replaceable provider, enforced by the backend
  • 📎 Files & PDF — secure uploads, automatic metadata, PDF generation (WeasyPrint)
  • 🔑 JWT auth + 2FA — simplejwt, OTP (pyotp) and QR codes built in
  • 🌍 Built-in i18n — file-based translations (pt-pt, en-us, es-es, fr-fr) and database-backed
  • 🌐 Dedicated middlewares — tenant context, frontend protection and file access control
  • 💵 Native money support (django-money)

⚙️ Installation & setup

pip install django_resaas
# or, for local development:
pip install -e .
# settings.py
INSTALLED_APPS = [
    "django_resaas.saas",           # the core
    "django_resaas.notifications",  # email / SMS / WhatsApp outbox
    "your_app",                     # your own modules
    ...
]

MIDDLEWARE = [
    ...
    "django_resaas.saas.core.middleware.file_access.FileAccessMiddleware",
    "django_resaas.saas.core.middleware.tenant.TenantContextMiddleware",
]

The complete, working settings (REST framework, JWT, CORS, RESAAS_*) are in Installation. Then:

python manage.py migrate
python manage.py create_root
python manage.py runserver

🧠 Architecture

EntityType
   ↓
Entity (tenant)
   ↓
Branch
   ↓
Group ──→ Permission

Person ──→ User ──→ BranchUserGroup (User + Branch + Group)

Business modules (HR, Health, Sales, ...) are separate Django apps built on this core; the framework itself ships none.

Key concepts:

Concept Role
Entity The tenant — typically the client/company
Branch A unit/location within an Entity
Person Human data (name, email, contacts)
User Authentication
EntityType The kind of tenant; carries default groups and modules
BranchUserGroup Links User + Branch + Group, allowing multiple groups per branch

🧪 Full example in 3 files

Model

from django.db import models
from django_resaas.saas.core.base.models import BaseModel

class Product(BaseModel):
    name = models.CharField(max_length=150)
    price = models.DecimalField(max_digits=12, decimal_places=2)

BaseModel already ships entity, branch, created_at/updated_at, created_by/updated_by and soft delete.

Serializer

from django_resaas.saas.core.base.serializers import BaseSerializer

class ProductSerializer(BaseSerializer):
    class Meta:
        model = Product
        fields = "__all__"

View

from django_resaas.saas.core.base.views import BaseAPIView, register_view

@register_view("products", module="your_app")
class ProductAPIView(BaseAPIView):
    queryset = Product.objects.all()
    serializer_class = ProductSerializer

(registerView is the same decorator under its original name, still supported.) The module must be activated for the Entity (App + EntityApp) — see the Quick start.

That's enough to automatically get: full CRUD, multi-tenant isolation, permissions, search, soft delete, restore, and protection based on the active module.


🔐 Multi-tenancy & RBAC

Tenant context is never trusted from raw client-supplied values. It travels as a single signed, short-lived token, issued by the API after checking the user actually has access to the Entity/Branch/Group requested.

1. Issue a context, once the user is authenticated:

POST /api/resaas/context/
Authorization: Bearer <access_token>

{
  "entity_id": "...",
  "branch_id": "...",   // optional
  "group_id": "..."     // optional
}

ResaasContextService validates access (via EntityUser / BranchUser / BranchUserGroup, with a superuser/entity-admin bypass) and signs the result with django.core.signing — versioned and bound to a TTL (1h by default, RESAAS_CONTEXT_TTL setting):

{ "token": "<signed-context-token>", "context": { "entity_id": "...", "branch_id": "...", "group_id": "..." } }

2. Send it back on every request, alongside auth and language — three headers, one job each:

Header Purpose
Authorization Bearer <JWT> — who you are
X-RESAAS-Context signed tenant context — where you're operating (entity/branch/group)
L active language id

TenantContextMiddleware decodes the token and verifies its signature and expiry on every request, exposing:

request.entity_type_id
request.entity_id
request.branch_id
request.group_id

BaseAPIView then re-validates that the context still belongs to the authenticated user (ResaasContextService.validate_for_user) before touching the queryset — a forged, expired, or replayed token from another user/tenant is rejected even if it was valid at issue time.

If a resource's module isn't active for the Entity, access is blocked automatically — no extra code in the view.

⚠️ Breaking change from earlier versions: the old scheme (raw ET / E / S / G headers sent directly by the client) has been replaced by the signed X-RESAAS-Context token above. If you're upgrading, swap those headers for a call to POST /resaas/context/ and forward the returned token instead.


🔁 Soft delete

obj.delete()        # soft delete
obj.restore()       # restore
obj.hard_delete()   # permanently delete
Model.objects           # active only
Model.deleted_objects    # deleted only
Model.all_objects        # everything

🔎 Automatic search & filters

GET /api/your_app/products/?search=john

BaseAPIView automatically searches text fields and relations (ForeignKey), with no per-endpoint configuration required.


🧩 Per-client modules & entitlements

Each Entity only sees the modules it has activated:

Entity Module Status
Company A Sales ✅
Company A CRM ❌

Activation is a direct App ↔ Entity link via EntityApp (toggled with its state field):

EntityApp.objects.get_or_create(app=app, entity=entity, state='Active')

Entitlements add what the installation/tenant may use, on top of activation: features (multi_entity), capacities (quantitative limits such as branches) and allowed modules. They are off by default (nothing restricted), configured with RESAAS_ENTITLEMENTS or a custom provider, and always enforced by the backend:

# illustrative values - RESAAS ships no plans or official limits
RESAAS_ENTITLEMENTS = {"features": {"advanced_audit": True},
                       "capacities": {"branches": 3, "users": 20}}

Entitlements sit between the tenant context and permissions — they never replace a permission:

Authentication → Signed tenant context → Entitlements → Permissions → Object scope → Field authorization → Business operation

Installing the package does not mean unlimited use: what an installation may use follows the license and its entitlements. The framework knows capabilities only — commercial plans are mapped to them by a provider. There is no billing or payment layer. See Entitlements.


🌐 Middlewares

Middleware Responsibility
TenantContextMiddleware Decodes the signed X-RESAAS-Context token and resolves entity, branch, group (L header for language)
FrontEndMiddleware Protects access via FEK/FEP frontend credentials and route/HTTP-method permissions
FileAccessMiddleware Controls access to protected files and media

🌍 Internationalization (i18n)

Translations are resolved in cascade — database first, then each app's lang/ files — with automatic caching:

from django_resaas.saas.core.utils.translate import Translate

Translate.tdc(request, "Register")

Languages included out of the box: pt-pt, en-us, es-es, fr-fr.


🛠 CLI / management commands

python manage.py setup             # initial SaaS bootstrap
python manage.py create_entity     # creates a new Entity (tenant)
python manage.py create_root       # creates the root user
python manage.py sync_language     # loads the default languages
python manage.py sync_actions      # syncs views registered in VIEW_REGISTRY
python manage.py check              # Django's system check framework
python manage.py check_metano       # validates compliance with the MetanoStack standard

🧰 Tech stack

Layer Technology
Backend Django 5.2 + Django REST Framework
Auth djangorestframework-simplejwt, 2FA (pyotp, qrcode)
Database PostgreSQL (psycopg)
Documents WeasyPrint (PDF), python-barcode
Filtering django-filter
Money django-money
Deployment Gunicorn

📚 Documentation

Full technical documentation lives in docs/:


🚀 Roadmap

  • Stripe integration
  • Billing dashboard
  • Resource auto-router
  • Action auditing
  • Multi-tenant logs
  • Permission cache (Redis)

🤝 Contributing

Pull requests are welcome. For larger changes, please open an issue first to discuss direction.

git clone https://github.com/metanochava/django_resaas.git
cd django_resaas
pip install -e .
make check

📄 License

Distributed under the RESAAS Commercial License. The package can be installed and used within the terms of that license and the entitlements enabled for your installation; anything beyond that needs a written license. Versions published before this license keep the license they were published with.


Made by Metano Chavana

Metadata

Release files for django-resaas 0.0.643

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-resaas 0.0.643
File Size Uploaded
django_resaas-0.0.643.tar.gz 389.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-resaas 0.0.643
File Interpreter ABI Platform
django_resaas-0.0.643-py3-none-any.whl Python 3 none any Details

Total release size: 909.2 kB

Release files / django_resaas-0.0.643.tar.gz

Download URL django_resaas-0.0.643.tar.gz
Size 389.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f8c5b7de16588a38f36d578a76e63c0884fe8223f36b1093d2d42b6bd4973928
BLAKE2b-256 checksum
How to use checksums
0450e1ffd8060dc617276f1fac67895c102cd635e842d41ee658161fe88aa401
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 Oct 11, 2026.

Transparency log

Release files / django_resaas-0.0.643-py3-none-any.whl

Download URL django_resaas-0.0.643-py3-none-any.whl
Size 519.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc9c010c7b492bb3fb69ee754e5e8b3400fc4f5fff4a3bf1bad99e348b6f5f02
BLAKE2b-256 checksum
How to use checksums
54777d765fb03220f110b02e3d673c2fe2b89f8dd2902cd7ca1627de376ceaf3
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 Oct 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.643 This release

2 release files

0.0.99

2 release files

0.0.97

2 release files

0.0.96

2 release files

0.0.94

2 release files

0.0.93

2 release files

0.0.62

2 release files

0.0.61

2 release files

0.0.60

2 release files

0.0.59

2 release files

0.0.58

2 release files

0.0.57

2 release files

0.0.56

2 release files

0.0.55

2 release files

0.0.54

2 release files

0.0.49

2 release files

0.0.48

2 release files

0.0.47

2 release files

0.0.46

2 release files

0.0.45

2 release files

0.0.44

2 release files

0.0.43

2 release files

0.0.42

2 release files

0.0.41

2 release files

0.0.40

2 release files

0.0.39

2 release files

0.0.38

2 release files

0.0.37

2 release files

0.0.36

2 release files

0.0.35

2 release files

0.0.34

2 release files

0.0.33

2 release files

0.0.32

2 release files

0.0.31

2 release files

0.0.30

2 release files

0.0.29

2 release files

0.0.28

2 release files

0.0.27

2 release files

0.0.26

2 release files

0.0.25

2 release files

0.0.24

2 release files

0.0.23

2 release files

0.0.22

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

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