django-tenantkit
A Django-native multitenancy framework focused on explicit isolation strategies, clear shared-versus-tenant boundaries, and integration with Django middleware, routing, admin, and provisioning workflows.
Why this package?
Multi-tenant Django systems often need different trade-offs depending on scale, operational model, and isolation requirements. Some solutions focus primarily on PostgreSQL schema isolation, while others assume a narrower routing or provisioning model.
This project aims to provide a more flexible foundation for Django applications that need:
- explicit tenant isolation strategies
- clear separation between shared/public and tenant-scoped data
- Django-native integration points instead of a parallel platform model
- a path toward a reusable package plus a reference example project
Supported isolation strategies
The framework currently supports two primary isolation modes:
| Strategy | Description | Best fit |
|---|---|---|
schema |
Multiple PostgreSQL schemas inside one shared database | Shared infrastructure with strong logical isolation |
database |
A dedicated database per tenant | Stronger operational isolation and backend flexibility |
The shared/public control plane remains separate from tenant-scoped runtime behavior.
See Concepts for the model vocabulary and architectural terms.
Audit and soft-delete
All framework models include mandatory audit tracking via django-auditkit:
created_at,updated_at,deleted_at— timestampscreated_by,updated_by,deleted_by— user tracking (foreign keys toAUTH_USER_MODEL)
This provides:
- Soft delete — records are marked deleted but retained for audit/history
- User attribution — every change is traceable to a user
- Recovery — soft-deleted records can be restored
The framework models (Tenant, TenantInvitation, TenantSetting) all inherit from AuditModel and include these fields automatically. The admin interface shows audit information in a collapsed section at the bottom of each form.
Installation
This repository uses a package-first layout.
The reusable package lives under src/tenantkit, while example/ contains the reference Django project.
For the current setup and integration path, see:
Minimal quickstart
At a high level, a Django project using the framework will:
- add the multitenancy app to
INSTALLED_APPS - add tenant-aware middleware
- add the tenant database router
- define shared and tenant-scoped models
- create one or more tenants
- run the appropriate migration workflow
The current reference Django project lives in example/, while the package source lives in src/tenantkit.
For the guided flow, see Quickstart.
Quick Configuration
Critical: The order of INSTALLED_APPS and MIDDLEWARE matters. See Setup Standard Guide for full details.
# settings.py - Minimal working configuration
INSTALLED_APPS = [
# Django core FIRST (auth before tenantkit)
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
# TenantKit AFTER auth
"tenantkit",
# Your apps
"myapp",
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.common.CommonMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware", # BEFORE
"tenantkit.middleware.TenantMiddleware", # AFTER
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
]
DATABASE_ROUTERS = ["tenantkit.routers.TenantRouter"]
TENANTKIT_BOTH_APPS = [
"django.contrib.auth",
"django.contrib.contenttypes",
]
Why this order matters:
django.contrib.authmust come beforetenantkitso User/Group/Permission models register first in thepublicschemaAuthenticationMiddlewaremust come beforeTenantMiddlewareso authentication happens inpublicbefore switching to the tenant schema
Official test command
The current stable validation path is:
uv sync --dev
uv run python example/manage.py test tenantkit
For local development, the repository is managed from the root and the example project acts as a consumer of the package.
See Testing for the current testing entrypoints.
Example project
The repository includes a Django reference project in example/.
It currently serves as:
- the integration environment
- the test harness
- the reference wiring for settings, middleware, routing, and admin behavior
The reusable package itself lives in src/tenantkit.
See Example Project.
Documentation
Public documentation:
- Installation
- Setup Standard Guide - Start here for configuration order
- Configuration Guide
- Quickstart
- Concepts
- Commands
- Provisioning
- Testing
- Example Project
- API Reference
Technical and architectural material:
Compatibility
| Project status | Python | Django |
|---|---|---|
| Current main branch | 3.12, 3.13 | 6.0 |
- Schema isolation requires PostgreSQL
- Database isolation depends on backend-specific provisioning and runtime support
Status
This project is under active development.
Current transition goals include:
- refining the public documentation structure
- stabilizing the new package-first repository layout
- keeping the
example/project as the reference integration environment
Contributing
See CONTRIBUTING.md. All changes should go through Pull Requests.
License
MIT License. See LICENSE.
Metadata
Release files for django-tenantkit-core 0.3.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django_tenantkit_core-0.3.4.tar.gz | 72.5 kB | With provenance | Details for django_tenantkit_core-0.3.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_tenantkit_core-0.3.4-py3-none-any.whl | Python 3 | none | any | Details for django_tenantkit_core-0.3.4-py3-none-any.whl |
Total release size: 165.6 kB
Release files / django_tenantkit_core-0.3.4.tar.gz
| Download URL | django_tenantkit_core-0.3.4.tar.gz |
|---|---|
| Size | 72.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3765d9d9f4806aef17d3ffcfcd0cb858dc8d7bf0e313cb3516c1031fc3ad5a80
|
|
BLAKE2b-256 checksum How to use checksums |
5c00515223171812271d385d85c65e1442d3904a7f5b97a9b22824e3770bb2a5
|
| 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 May 17, 2026.
Transparency logRelease files / django_tenantkit_core-0.3.4-py3-none-any.whl
| Download URL | django_tenantkit_core-0.3.4-py3-none-any.whl |
|---|---|
| Size | 93.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
25ec5e2f00963e154842fa31ca69bdeeda085c5a68b07b69a7fbb67f182c5072
|
|
BLAKE2b-256 checksum How to use checksums |
2ca1e7776ac7355899b1bd71e6ddb1d55a0b84eee988852b369af3000b9319ab
|
| 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 May 17, 2026.
Transparency logSecurity for django-tenantkit-core 0.3.4
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for django_tenantkit_core-0.3.4.tar.gz
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 May 17, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.