In our multi-tenant system (using Postgresql), we want to allow different tenants to "associate" with each other, and share some data. So if Tenant A is associated with Tenant B, when showing the shared data, our queries will need to get data from schema A AND schema B.
I've found examples that show how to do so with straight Postgresql code; something like this:
select * from S1.table1
UNION ALL
select * from S2.table1
...though ours would be much more complicated than that. But I've not found anything that explains how to do it with Django's ORM. In other words, how would I do the above with the query syntax we actually use in our site:
queryset = MyTable.objects.filter(client_id__in=clients, status=Status.ACTIVE)