django - Authenticating user problem with django-tenant-schema
问题描述
I want to have admin module available to tenants (using django-tenant-schema
).
My apps section of settings.py:
# Application definition
SHARED_APPS = (
'tenant_schemas', # mandatory, should always be before any django app
'customers', # you must list the app where your tenant model resides in
# 'django.contrib.sites',
# everything below here is optional
)
TENANT_APPS = (
'django.contrib.contenttypes',
# your tenant-specific apps
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
INSTALLED_APPS = (
'tenant_schemas', # mandatory, should always be before any django app
'customers',
# 'django.contrib.sites', #using this will cause error - see my stackoverflow question
'django.contrib.auth',
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
I have set up 2 schemas (tenant1 and public). Created superuser and can see that superuser is created within tenant1 schema. However when trying to log in at tenant1.domain.com/admin, getting login screen but after entering credentials keep getting:
ProgrammingError at /admin/login/ relation "auth_user" does not exist
Looks like it is not picking up my tenant1 schema? What I have to change in configuration?
解决方案
Make sure tenant middleware is installed.
It's responsible for negotiating which tenant is called and connecting to the right schemas.
推荐阅读
- laravel - 在 Laravel 5.8 迁移中,无法将外部列从可为空更改为不为空
- sql - 子查询应该总是选择语句吗?
- oracle - 如何通过更改计数值在 Oracle 中按组填写缺失的日期
- javascript - TypeScript 错误类型的参数不可分配给 Appstate 类型的参数,尽管包含了所有必要的类型
- azure - Azure 应用程序网关后端池负载均衡器
- android - Android:更新菜单工具栏
- node.js - 对于 node-postgres(“pg”库),会话变量在行级安全性方面是否安全?
- javascript - 如何使用js模拟输入那些元素。谢谢
- javascript - “对象不是函数”Polymer 3 包装器
- python - Pydub wma to mp3 修复“库配置不匹配”