{"repo":"raphaelm/django-scopes","free":true,"listed":false,"github":"https://github.com/raphaelm/django-scopes","clone":"git clone https://github.com/raphaelm/django-scopes.git","description":"Safely separate multiple tenants in a Django database","language":"Python","stars":261,"topics":["django"],"license":"Apache-2.0","category":"databases-storage","readme_excerpt":"django-scopes ============= Motivation ---------- Many of us use Django to build multi-tenant applications where every user only ever gets access to a small, separated fraction of the data in our application, while at the same time having some global functionality that makes separate databases per client infeasible. While Django does a great job protecting us from building SQL injection vulnerabilities and similar errors, Django can't protect us from logic errors and one of the most dangerous types of security issues for multi-tenant applications is that we leak data across tenants. It's so easy to forget that one .filter call and it's hard to catch these errors in both manual and automated testing, since you usually do not have a lot of clients in your development setup. Leaving radical, database-dependent ideas aside, there aren't many approaches available in the ecosystem to prevent these mistakes from happening aside from rigorous code review. We'd like to propose this module as a flexible line of defense. It is meant to have little impact on your day-to-day work, but act as a safeguard in case you build a faulty query. Installation ------------ There's nothing required apart from a simple pip install django-scopes Compatibility ------------- This library is tested against Python 3.10-3.13 and Django 4.2-5.1 . Usage ----- Let's assume we have a multi-tenant blog application consisting of the three models Site , Post , and Comment : In this case, our model Site acts as the","default_branch":null,"files":null,"tree":[],"storefront":"/r/raphaelm","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/raphaelm/django-scopes/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}