Django library to implement multi-tenant databases, primarily targeting Citus (PostgreSQL extension for horizontal scaling). Supports Django 3.2 to 5.0 with Python 3.8+. Provides mixins, managers, and utilities to isolate tenant data via a tenant_id column. Release cadence is irregular, with the latest stable version 4.1.1 from 2024.
pip install django-multitenantVerified import paths — ran on the pinned version, not inferred.
Define a Tenant model and a tenant-aware model using TenantModelMixin.
Change import to from django_multitenant.mixins import TenantModelMixin
class MyModel(TenantModelMixin, models.Model): ...
Explicitly define a through model with a ForeignKey to the tenant model.
Use TenantModelMixin with models.Model instead of inheriting TenantModel.