帮助创建共享模式多租户应用程序的lib
django-shared-schema-tenants的Python项目详细描述
一个lib来帮助创建具有共享模式的应用程序
快速启动
安装django共享架构租户:
pip install django-shared-schema-tenants
将其添加到已安装的应用程序中
INSTALLED_APPS=(...'shared_schema_tenants.apps.SharedSchemaTenantsConfig',...)
添加django共享架构租户的url模式:
fromshared_schema_tenantsimporturlsasshared_schema_tenants_urlsurlpatterns=[...url(r'^',include(shared_schema_tenants_urls)),...]
将TenantMiddleware添加到您的中间产品:
MIDDLEWARES=[# ...'shared_schema_tenants.middleware.TenantMiddleware',# ...]
功能
- Tenants与django请求同步:可以从请求的域和特定的http头属性中提取活动的租户
- 租户之间的简单数据隔离:检索和创建数据的方式与不使用租户时相同。活动租户可以从请求中检索,也可以强制设置
- 部分共享数据:如果应用程序中有多个租户可以访问的数据,则无需复制它
运行测试
代码真的有用吗
source <YOURVIRTUALENV>/bin/activate (myenv) $ pip install tox (myenv) $ tox
历史
0.1.0(2017-08-10)
- pypi上的第一个版本。