简体   繁体   English

如何获得在相同域上运行,共享用户数据库,但具有不同(和隔离)应用程序模型的任意数量的django应用程序?

[英]How to get arbitrary number of django apps running on same domain, sharing User database, but with different (and isolated) app models?

I am trying to decide how to implement this architecture. 我正在尝试决定如何实现此体系结构。 I have a base Django package, let's call it BaseApp. 我有一个基本的Django程序包,我们称它为BaseApp。 I have been developing this for distribution as a tool for others to use. 我一直在开发此发行版,以作为其他人使用的工具。 BaseApp defines some view behavior and some base models, mostly. BaseApp主要定义了一些视图行为和一些基本模型。 A developer can install BaseApp, and then make another app, let's call it NeatThing, that only has to define a few models and templates, and BaseApp does the rest, and for very little effort they now have a mini-application that Does Their Neat Thing. 开发人员可以安装BaseApp,然后制作另一个应用程序,我们称之为NeatThing,只需定义几个模型和模板,其余的则由BaseApp进行,而他们现在只需很少的工作即可拥有一个微型应用程序事情。 Repeat x 100, and we have 100 different developers doing 100 different Neat Things. 重复x 100,我们有100个不同的开发人员执行100个不同的Neat Things。 And they all work just peachy as separate servers in separate environments, etc. 而且它们在单独的环境中作为单独的服务器等都工作得很好。

Now I want to take that and provide 1 version of BaseApp, and 1 database of users, and all 100 different Neato-Whiz-Bang applications, and serve them together on one domain, so users all come to the same place. 现在,我想采用该功能,并提供1个版本的BaseApp,1个用户数据库以及所有100个不同的Neato-Whiz-Bang应用程序,并将它们一起提供给一个域,因此用户都来到同一个地方。

How do I do that so that: 我该怎么做,以便:

  1. 1 URL points to one of the 100 different applications (programmatically in a way I configure) 1个URL指向100个不同应用程序之一(以我配置的方式编程)
  2. ensure the 100 different applications are isolated from each other (can't interact with each other at all) 确保将100个不同的应用程序彼此隔离(完全不能交互)
  3. give each application (limited) access to the User database so that users can be associated with the models in their application (I am aware of Django multi-database support - but how can I secure one user database while giving each application access?) 授予每个应用程序(有限的)访问User数据库的权限,以便可以将用户与其应用程序中的模型相关联(我知道Django多数据库支持-但是如何在授予每个应用程序访问权限的同时保护一个用户数据库的安全?)

I am asking this as a high-level implementation approach standpoint. 我问这是一个高级实施方法的观点。 Ie which direction do I go from here? 即我从这里去哪个方向?

What you're describing sounds a lot like what postgresql tries to accomplish with schemas . 您所描述的内容听起来很像PostgreSQL尝试使用模式来完成的事情。 See django-tenant-schemas for an excellent implement implementation of this approach in django. 请参阅django-tenant-schemas ,以了解在django中此方法的出色实现。 Disclaimer: I'm a contributor to that project. 免责声明:我是该项目的参与者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM