bernardopires / django-tenant-schemas

Tenant support for Django using PostgreSQL schemas.
https://django-tenant-schemas.readthedocs.org/en/latest/
MIT License
1.45k stars 425 forks source link

Accessing tenants data from public. #671

Open PathakHarsh opened 3 years ago

PathakHarsh commented 3 years ago

Suppose I have two tenants. First is on domain 'user1.localhost' and the second is on domain 'user2.localhost'

When I am using public schema (localhost:8000),In my views,I want to get the data from the tenant schemas.How can I achieve this ?

tarsilcol commented 2 years ago

So what I did was this:

  1. Created a table that maps a user of the system with a Tenant (Client)
  2. When a Client is created, I associate with a user
  3. Query that table to know which tenants are associated with the given logged in user
  4. Use that information to pass in the HEADER when querying