django-multitenant
django-multitenant copied to clipboard
Python/Django support for distributed multi-tenant databases like Postgres+Citus
We have models that have a tenant field set as `tenant = ....` and django therefore generates tenant_id as part of the django model. This collides with the usage of...
python:3.6.6 django:2.2.6 models.py ``` from django.db import models from django_multitenant.fields import TenantForeignKey from django_multitenant.models import TenantModel class Tenant(TenantModel): tenant_id = "id" name = models.CharField("tenant name", max_length=100) class Business(TenantModel): tenant =...
When using a `ManyToManyField `with a through model, the tenant_id is not applied to the through model when the parent instance is saved. Consider the following: ``` class Store(TenantModel): tenant_id...
Thank you for providing this library for free. I think it is very valuable. I'm struggling to get the library to work for my setup, though. I created a tenant...
Suppose I have the following 2 models and a model form ` class CostCenter(ClientModelMixin, models.Model): tenant_id = 'client_id' client = models.ForeignKey('accounts.Client', on_delete=models.CASCADE) name = models.CharField(max_length=50) objects = TenantManager() class Account(ClientModelMixin,...
Problem: sql-clause `"table"."tenant_id" = current_tenant_value` dissapers from query for django-filter's ModelChoiceFilter when `order_by` is added to queryset. Code to reproduce. `models.py` ``` python from django_multitenant.fields import TenantForeignKey from django_multitenant.mixins import...
Suport for models like this: `class Task(TenantModel):` ` tenant_id = 'business_id'` ` business = models.ForeignKey(Business, on_delete = models.CASCADE)` ` sub_task = TenantForeignKey(` ` 'self',` ` on_delete=models.CASCADE,` ` db_index=False,` ` blank=True,`...
To use TenantModel with Django Rest Framework's ViewSets, the following refactor was necessary: ```python # before class MyModelViewSet(GenericViewSet): queryset = MyModel.objects.all() ``` ```python # after class MyModelViewSet(GenericViewSet): def get_queryset(self): return...
One important pre-requisite for migration to citus is for all the models which are inherited from TenantModel, we need to replace the primary key on id column to a composite...
Does this package support the use of sub-domains or does this need to be implemented separstely or with another package like django-subdomains or django-hosts?