An approach to lightweight tenancy management using Django Rest Framework
summary
Presents a working lightweight multitenancy approach for shared-schema apps using Django REST Framework with nested URLs via drf nested routers, users allowed in multiple tenants, and a viewset that overrides initial to look up the tenant from the requesting user so unauthorized tenant access returns 404. Adds a company-aware manager that forbids .all and requires a company filter to avoid accidental leaks. Notes it fails for per-tenant schemas and admin access is unchecked, and suggests drf access policy as a richer alternative.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 0:23Multi-tenancy overview
- 3:50Lightweight requirements
- 5:36Implementation approach
- 7:42Custom user viewset
- 10:31Model managers for leaks
- 15:07Limitations
- 16:32DRF Access Policy alternative
- 19:22Conclusions
related talks
27mWhat You Should Know About Django REST Framework
26mDjango, REST and OpenAPI - a gentle introduction
26mWhat it's really like building RESTful APIs with Django
25mWrite an API for Almost Anything (or The Amazing Power and Flexibility of Django Rest Framework)
30mA state of REST.
37mBuilding Scalable Multi-Tenant Frontend Architecture for a B2B E-Commerce Platform
50mMultitenancy from scratch
01h 00mReusable Apps
