{"id":23584,"library":"django-multitenant","title":"django-multitenant","description":"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.","status":"active","version":"4.1.1","language":"python","source_language":"en","source_url":"https://github.com/citusdata/django-multitenant","tags":["django","multitenant","citus","postgresql","saas"],"install":[{"cmd":"pip install django-multitenant","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Core dependency, supports 3.2+","package":"Django","optional":false}],"imports":[{"wrong":"from django_multitenant.mixins import TenantModelMixin","symbol":"TenantModelMixin","correct":"from django_multitenant.mixins import TenantModelMixin"}],"quickstart":{"code":"import os\nfrom django.db import models\nfrom django_multitenant.mixins import TenantModelMixin\nfrom django_multitenant.models import TenantModel\n\nclass Tenant(models.Model):\n    tenant_id = models.AutoField(primary_key=True)\n    name = models.CharField(max_length=100)\n\nclass Project(TenantModelMixin, models.Model):\n    tenant = models.ForeignKey(Tenant, on_delete=models.CASCADE)\n    name = models.CharField(max_length=100)\n\n    class Meta:\n        app_label = 'myapp'\n\n# In your settings, ensure DATABASES and MIDDLEWARE are configured\n# See https://django-multitenant.readthedocs.io/","lang":"python","description":"Define a Tenant model and a tenant-aware model using TenantModelMixin."},"warnings":[{"fix":"Change import to from django_multitenant.mixins import TenantModelMixin","message":"In v3.0.0, TenantModelMixin was moved from django_multitenant.models to django_multitenant.mixins. Old imports will break.","severity":"breaking","affected_versions":"<3.0.0"},{"fix":"class MyModel(TenantModelMixin, models.Model): ...","message":"TenantModelMixin must be listed before models.Model in the class definition to avoid MRO issues.","severity":"gotcha","affected_versions":"all"},{"fix":"Explicitly define a through model with a ForeignKey to the tenant model.","message":"When using ManyToMany fields between tenant models, the intermediate table may not include the tenant column automatically. You must define a through model with tenant_id.","severity":"gotcha","affected_versions":"all"},{"fix":"Use TenantModelMixin with models.Model instead of inheriting TenantModel.","message":"The TenantModel base class is deprecated in favor of TenantModelMixin + models.Model.","severity":"deprecated","affected_versions":">=3.0.0"}],"env_vars":null,"search_vec":"'2024':53 '3.2':22 '3.8':27 '4.1.1':51 '5.0':24 'cadenc':43 'citus':14,56 'column':41 'data':36 'databas':11 'django':2,4,21,54 'django-multiten':1 'extens':16 'horizont':18 'id':40 'implement':7 'irregular':45 'isol':34 'latest':48 'librari':5 'manag':30 'mixin':29 'multi':9 'multi-ten':8 'multiten':3,55 'postgresql':15,57 'primarili':12 'provid':28 'python':26 'releas':42 'saa':58 'scale':19 'stabl':49 'support':20 'target':13 'tenant':10,35,39 'util':32 'version':50 'via':37","created_at":"2026-05-01T08:08:32.758435+00:00","updated_at":"2026-05-01T08:08:32.758435+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmpxxni9kxj/venv/lib/python3.12/site-packages/django_multitenant/__init__.py\", line 2, in <module>\n    import django\nModuleNotFoundError: No module named 'django'"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"4.1.1","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/citusdata/django-multitenant","docs":null,"changelog":null,"pypi":"https://pypi.org/project/django-multitenant/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["database","web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}