--- id: django-tenants version: "3.14.0" license: MIT license_treatment: permissive maintenance: active --- # django-tenants — Tenant support for Django using PostgreSQL schemas. License: permissive · Maintenance: active · Downloads: 958.4K/mo ## What it is and what it does django-tenants is a Django extension that implements the semi-isolated multitenancy pattern: one PostgreSQL database with separate schemas per tenant. It intercepts requests by hostname, routes them to the correct tenant schema, and makes all ORM queries operate transparently within that schema without requiring changes to your view code. The package manages schema creation, migration routing (shared vs. tenant-specific), and provides middleware to automatically set the PostgreSQL search path on each request. You define a tenant model (e.g., Client) and a domain model to map hostnames to tenants. When a request arrives at tenant.example.com, the middleware looks up the tenant, sets the schema, and all subsequent database operations happen in that tenant's isolated space. This approach balances simplicity—minimal code changes needed—with performance benefits of shared connections and buffers compared to fully separate databases. Use it for: - Build a SaaS platform where each customer's data must be isolated but served from a single Django instance - Implement different views or configurations per tenant while reusing the same codebase and database connection pool - Manage shared data (e.g., billing, user accounts) in the public schema while keeping customer-specific tables in tenant schemas - Scale horizontally by running multiple application instances against the same PostgreSQL database with automatic tenant routing ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Enables Django applications to serve multiple tenants from a single instance using PostgreSQL schemas, where each tenant's data is isolated in its own schema while sharing the application code. Yes. django-tenants is production-stable (Development Status 5), actively maintained, has no known vulnerabilities, and solves a real architectural problem for SaaS applications. The single django dependency and permissive MIT license remove friction. Install if you need schema-based multitenancy on PostgreSQL; it requires Django 2+ and PostgreSQL, and you must be comfortable with PostgreSQL schema concepts. ## Install pip install django-tenants uv add django-tenants poetry add django-tenants ## Installing django-tenants Before you install: Low install friction with a single runtime dependency on django. Actively maintained with recent releases and a stable codebase (1882 GitHub stars, last commit 2026-08-10). License in practice: MIT license permits commercial use, modification, and distribution with minimal restrictions—suitable for proprietary SaaS applications. Quickstart: # Install pip install django-tenants # In settings.py DATABASES = { 'default': { 'ENGINE': 'django_tenants.postgresql_backend', # ... } } MIDDLEWARE = ( 'django_tenants.middleware.main.TenantMainMiddleware', # ... ) INSTALLED_APPS = [ 'django_tenants', # ... ] TENANT_MODEL = "customers.Client" TENANT_DOMAIN_MODEL = "customers.Domain" # In models.py from django_tenants.models import TenantMixin, DomainMixin class Client(TenantMixin): name = models.CharField(max_length=100) class Domain(DomainMixin): pass # Run migrations python manage.py migrate_schemas --shared Requires PostgreSQL database backend and Django 2+; Python 3.10 or later. Verify before relying: - Whether the package handles tenant-specific migrations automatically or requires manual intervention - Performance characteristics under high tenant counts or concurrent request loads - Compatibility with Django's async views and async ORM features ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 958.4K/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags django multitenancy postgres schemas, saas tenant isolation django, django multiple customers one instance, postgresql schema-based tenants, django tenant routing by domain, multitenancy, saas, postgresql [View on SkillFed](https://skillfed.io/packages/django-tenants) · [View on PyPI](https://pypi.org/project/django-tenants/)