Django multi-user saas

a 夏天 提交于 2019-12-04 18:35:34

I don't know of any way to automatically filter querysets based on request.user. This is because the ORM is not coupled with django.contrib.auth.

I tried two SaaS designs:

  1. 1 database for all sites, and manual filtering on all querysets. Of course this made django.contrib.admin not possible out of the box. It might be possible to enable django.contrib.admin with a really tight setup of django-authority or maybe even other django per-object permission packages (google cached version because djangopackages.com is down ATM).

  2. 1 database per site, that's just easier, keeps the code cleaner, and enables django.contrib.admin out of the box, which can be really cool if you install a django admin theme. Also I enabled django.contrib.admindoc as well as django-dbtemplates.

(Apparently in your case, 1 site = 1 user, but the concept is the same)

I prefer the second implementation because it's obviously a lot less development work, which is compensated by a little system administration.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!