A tenant/workspace
is the core model which establishes a hierarchy for linking apps (including payments, teams) and users.
Tenant logic is applied to the data layer. Tenants share the same database and schema. There is a main tenant table, to which all other Tenant-Aware tables must be linked via foreign keys.
Queries are filtered based on the tenant_id for the tenant-aware models. Each tenant model includes a custom manager for filtering the queryset based on the tenant.
TenantModelMixin
which inserts a tenant_id field on the model.TenantModelManagerMixin
objects
manager must be replaced with the new custom manager.Please note that this is distinct from the Teams feature.
An app can be in one of three TenantModes:
The tenant mode must be set up during configuration but can be changed from config/settings/mixins/multi_tenant.py
.
SINGLE_TENANT - All users belong to the same tenant. i.e. One workspace for all tenants.
SINGLE_TENANT_PER_USER - User belongs to one tenant. Tenant/Workspace cannot have more than one user.
MULTI_TENANT_PER_USER - User belongs to multiple tenants/workspaces. Each tenant/workspace can have multiple users
Each user is assigned one of the following roles:
ROLE_MEMBER = "member"
ROLE_MANAGER = "manager"
ROLE_OWNER = "owner" - assigned to a single user, the owner of the workspace.
Tenant roles for managers and members can be changed by owners directly from the dashboard.
Success
Error
Warning
Info