Replies: 2 comments 2 replies
-
Users can either be placed at the tenant level, or at the system level. If you place users at the tenant level, then users will be enclosed in that tenant, and one user will not be accessible outside the scope of its own tenant. If you place users at the system level, users will have access to all tenants, and you must provide yourself a "binding" between users and tenants, so that authentication / authorization behaves accordingly. These are the only options. In your case, seems like you need users to be able to access multiple tenants. For that, you must place your user model in the public schema, and you must have in place your own control for determining which users have access to which schemas (e.g. User -> Tenant M2M relation.) With that, your authentication mechanism should check not only validity of credentials, but also whether the authenticating user has access to the target tenant. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the very well described answer. I appreciate it and it seems I'll need to be reading up more on Django in general to accomplish this. Thanks again and great library! |
Beta Was this translation helpful? Give feedback.
-
I've been playing around with this for a while and what I want to accomplish is multitenancy where each tenant can access their own admin. I've gotten as far as actually getting /admin to work but I can't create an admin user for the tenant. How is this done?
Also, what is the best way to set up the main application where I can manage the customers / tenants?
Here is my settings.py configuration:
Whenever I try to createsuper on for the base site, I get this:
django.db.utils.ProgrammingError: relation "auth_user" does not exist LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "auth_user...
I'm in dev and just experimenting so if I have to start over, I'm fine with it. I think this last issue with creating superusers is because of a migration mistake I made.
Beta Was this translation helpful? Give feedback.
All reactions