An approach to lightweight tenancy management using Django Rest Framework
December 15, 2023
21 min
Free
django
python
django-rest-framework
api-design
multi-tenancy
database-design
software-architecture
access-control
orm
web-development
Description
This talk presents a lightweight multitenancy approach using Django Rest Framework, focusing on a common use case where tenants share a database and application instance, but resources belong to a single tenant. The presentation covers techniques for nesting API routes and consistently restricting access to resources, including the use of custom viewsets, model managers, and the drf-nested-routers library. It also explores the drf-access-policy library as an alternative for more complex permission logic. Limitations such as the need for identical table structures across tenants and checks only at the API level are also discussed.