$npx skillfedfor your agent

django-multitenant

Django Library to Implement Multi-tenant databases

Worth itPyPI DatabaseReleased Dec 2023169.6K downloads / mopermissive licensePure Python

Decision gist · record as of 2026-08-14

pure-Python wheel — django_multitenant-4.1.1-py3-none-any.whl
v4.1.1 · released 2023-12-18

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

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
Same gist for agents: .md · .json

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.

Worth 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

Licensepermissive license permissive
Python supportNot specified
Install frictionLow. Pure-Python wheel
Runtime dependenciesNone
MaintenanceActively maintained 970 days since the last release
Last repo commit
First released
Downloads169,585 / month, #10,416 on PyPI 30-day window, as of 2026-08-14
Known vulnerabilitiesNone 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

Capabilities
django multi-tenant databasetenant isolation ormcitus django integrationshared table multi-tenancypostgres tenant routingdjango tenant contextsaas database scaling
Topics
multi-tenantsaascitus
PyPI keywords
citusdjangomultitenantdjangopostgresmulti-tenant

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”

Give your agent the search over MCP, or paste the wish link into any chat.

More Database packages

psycopg2-binary Worth it
PyPI · Software Development · released Apr 2026

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.

copyleftcompiled wheel · 3.9+
271.6Mdownloads / mo
redis Worth it
PyPI · Database · released Jul 2026

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.

MITpure Python · 3.10+
268.3Mdownloads / mo
ydb Worth it
PyPI · Database · released Jul 2026

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.

permissive licensepure Python · 3.10+
210.0Mdownloads / mo
snowflake-connector-python Worth it
PyPI · Software Development · released Aug 2026

Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.

Apache-2.0compiled wheel · 3.10+
193.6Mdownloads / mo
sqlparse Worth it
PyPI · Software Development · released Aug 2026

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.

BSD-3-Clausepure Python · 3.10+
148.9Mdownloads / mo
dbt-adapters With conditions
PyPI · Database · released Jul 2026

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.

Apache-2.0pure Python · 3.10.0+
121.3Mdownloads / mo

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