django-multitenant
Django Library to Implement Multi-tenant databases
Decision gist · record as of 2026-08-14
Yes. The package is actively maintained, has no known vulnerabilities, carries a permissive MIT license, and solves a specific architectural problem (shared-table multi-tenancy) that would otherwise require manual tenant filtering throughout your codebase. Install it if you are building a multi-tenant Django application on Postgres+Citus or similar distributed databases.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Django to be installed separately; ensure your Django version matches the supported versions (3.2, 4.0, 4.1, or 4.2) for your Python version (3.7–3.11).
- Low install friction with no runtime dependencies.
- Active maintenance with recent commits and a stable release history since 2017; last release was 2023-12-18.
License · maintenance · safety
permissive license (permissive) — MIT license (permissive) allows commercial use, modification, and distribution with minimal restrictions.
last release 2023-12-18 (970 days) · last repo commit 2026-03-30 · 823 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 169,585 downloads/mo, #10,416 on PyPI
Alternatives
Verify before relying
pip install django-multitenant
from django_multitenant.models import TenantModel
from django_multitenant.fields import TenantForeignKey
from django_multitenant.utils import set_current_tenant
class Store(TenantModel):
name = models.CharField(max_length=50)
class TenantMeta:
tenant_field_name = "id"
class Product(TenantModel):
store = models.ForeignKey(Store)
name = models.CharField(max_length=255)
class TenantMeta:
tenant_field_name = "store_id"
set_current_tenant(store_instance)
products = Product.objects.all() # Automatically filtered by tenant- Whether the package requires Django to be installed separately or if it's specified as a dependency elsewhere
- Exact Python version support beyond the classifiers (3.7, 3.8, 3.9, 3.10, 3.11 listed)
- Performance characteristics when used with very large tenant datasets
What it is and what it does
django-multitenant is a Django library that implements multi-tenant database patterns where all tenants share the same tables but are isolated by a tenant_id column. It automatically injects tenant context into queries, allowing databases like Postgres+Citus to route queries efficiently to the correct shard or node without requiring separate databases or schemas per tenant.
The library provides two integration patterns: inherit from TenantModel or use TenantModelMixin with your existing Django models. It replaces standard ForeignKey with TenantForeignKey to maintain tenant relationships and includes middleware utilities to set tenant context per request. This approach scales horizontally by letting the database layer handle tenant-aware query routing rather than application-level filtering.
Use it for
- Building SaaS applications where multiple customers share infrastructure but need data isolation at the database level.
- Scaling Django apps on Postgres+Citus by automating tenant_id inclusion in all queries without manual filtering.
- Implementing composite foreign keys with tenant_id at the database layer to enforce referential integrity across tenant boundaries.
- Setting up multi-tenant middleware that automatically scopes all ORM operations to the current request's tenant.
- Migrating monolithic Django apps to a shared-table multi-tenant architecture without rewriting query logic.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The package is actively maintained, has no known vulnerabilities, carries a permissive MIT license, and solves a specific architectural problem (shared-table multi-tenancy) that would otherwise require manual tenant filtering throughout your codebase. Install it if you are building a multi-tenant Django application on Postgres+Citus or similar distributed databases.
Install
django-multitenant on PyPI
Before you install
Low install friction with no runtime dependencies. Active maintenance with recent commits and a stable release history since 2017; last release was 2023-12-18.
Requires Django to be installed separately; ensure your Django version matches the supported versions (3.2, 4.0, 4.1, or 4.2) for your Python version (3.7–3.11).
License in practice
MIT license (permissive) allows commercial use, modification, and distribution with minimal restrictions.
Quickstart
pip install django-multitenant
from django_multitenant.models import TenantModel
from django_multitenant.fields import TenantForeignKey
from django_multitenant.utils import set_current_tenant
class Store(TenantModel):
name = models.CharField(max_length=50)
class TenantMeta:
tenant_field_name = "id"
class Product(TenantModel):
store = models.ForeignKey(Store)
name = models.CharField(max_length=255)
class TenantMeta:
tenant_field_name = "store_id"
set_current_tenant(store_instance)
products = Product.objects.all() # Automatically filtered by tenant
Verify before relying
- Whether the package requires Django to be installed separately or if it's specified as a dependency elsewhere
- Exact Python version support beyond the classifiers (3.7, 3.8, 3.9, 3.10, 3.11 listed)
- Performance characteristics when used with very large tenant datasets
Package facts
| License | permissive license permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 970 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 169,585 / month, #10,416 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Database |
Evidence: django_multitenant-4.1.1-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “django multi-tenant database”
- django-multitenantAdds multi-tenant database support to Django by automatically scoping…
- django-organizationsAdds multi-user group and account management to Django, letting you…
- django-safedeleteProvides soft-delete functionality for Django models, allowing…
Give your agent the search over MCP, or paste the wish link into any chat.
More Database packages
psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.
Python client library for connecting to and executing commands against Redis key-value stores, supporting both synchronous and asynchronous operations.
Install it if your application needs to interact with Redis; the only prerequisite is a running Redis server instance.
YDB Python SDK is the official client library for connecting to and querying YDB databases from Python applications.
Install it if you need to connect Python applications to YDB databases.
Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.
sqlparse tokenizes SQL text into a tree of statements, clauses, and expressions, and provides functions to split scripts, format queries, and inspect parsed tokens without validating dialect or syntax.
Install it if you need to manipulate, format, or analyze SQL text programmatically.
Provides base adapter protocols and shared functionality that database adapters use to integrate with dbt-core, handling connections, dialect translation, relation caching, and core interface management.
See also django-tenants · tenant-schemas-celery · django-pgviews-redux · django-ordered-model · django-tree-queries · django-add-default-value · django-reverse-admin · django-pgtrigger · django-querycount · django-nested-inline