django-tenant-schemas
django-tenant-schemas copied to clipboard
How to manage all tenants users/data from single public tenant(Root)
I want control of all tenants from one tenant which one is public. For example,
- public schema - domain url is "localhost"
- Tenant1 schema - domain url is "tenant1.localhost"
- Tenant2 schema - domain url is "tenant2.localhost" Now from localhost, I want to add/remove users of tenant1 and tenant2 from their auth tables.
How can I do that?
Programmatically, you have 2 choices :
- Change django.db.connection.schema_name to each schema when listing, editing, deleting users
- Set search path to all schemas "SET search_path TO tenant2,tenant1,public" (execute a raw django query)
AFAICT that second option doesn't work; it will only show/expose the auth_user table from tenant2.
Is not there a solution for this where you can make a root tenant that can control all other tenants?
I keep my tenants in the public schema, which are accessible from the other tenants as well. Seems to work just fine.