Implementing Django Multi-tenants
Here's how we implemented multi-tenancy on a recent Python / Django app build. This article describes our approach, shares some code and compares it with an earlier project we did using a different method. In my last post about Multi-tenancy in Elixir using Ecto I described two approaches to implementing multi-tenancy: One solution for this would be to add a tenant_id column to every table in the database. All queries would then include this id. An alternative solution is to store each tenant’s data in a separate Postgres schema, and query against that. That first post describes the Postgres schema approach. On a recent project we made the opposite choice, and added tenant_id to every database record. On both projects the ask was very similar, to allow other organizations to “whitelabel” the application with their own branding but with completely distinct data. In this post I’ll describe the implementation, flag some rough spots that we didn’t initially catch, a...