0
votes

I began with django-tenant-schemas which creates postgresql schemas for separating tenants. I am new to django. Can anyone explain me

  1. How should a multi app project accommodate multi tenancy?
  2. django-tenant-schemas creates users specific to the tenant. How can I have users spread across multiple tenants.
1
What do you actually mean by "multi app"? Do you mean that there can be several "types" of tenants that not only have different databases but also different schemas and logic? Or your tenants should have several apps? Later is supported fy django-tenant-schemas out of the box. Different "Types" of tenants are not supported but you can fake it by using condition on some field of "TENANT_MODEL" (return 404 for apps of not "current" tenant apps. There are many other possibilities but you'd better specify what do you actualy mean by "multi app" - imposeren
I mean two apps. for example a polls app and a tasks app. So i just have to specify them in the shared apps? - eskawl
if each your tenant should have urls for 2 different apps then these apps should be used in TENANT_APPS (not shared apps!). Example from docs have 2 custom apps for each tenant: myapp.hotels and myapp.houses. Shared apps are used for "public" site wher you maybe "selling" your services. Note that you should also use different urlconf for 'public' tenant and for 'app-tenants' - imposeren
thanks that helps, How can I make users spread across tenants? - eskawl
There are several solutions: 1. build your apps to not depend on real FKs to users and use API to get user info or multiple databases (User.object.using('user_db)...' docs.djangoproject.com/en/1.9/topics/db/multi-db/…). 2. Sync users table (there are many problems involved but if you are using third-party django apps that depend on User relation than this is the only way) - imposeren

1 Answers

0
votes

Django-tenant-schemas itself provides support for multiple applications as stated by @imposeren int the comments to the question.

For user to be available across the sub-domains, the django.contrib.auth should only be mentioned in the sharedapps and not in the tenantapps.

Also SESSION_COOKIE_DOMAIN should be *.domain.com