gpt4 book ai didi

python - django-tenant-schema 为所有租户启用管理模块

转载 作者:行者123 更新时间:2023-12-01 08:56:04 27 4
gpt4 key购买 nike

我正在使用 Multi-Tenancy 架构设置 django。我浏览了https://django-tenant-schemas.readthedocs.io/en/latest/install.html说明并到达初始启动屏幕。我想要实现的是为每个租户启用管理模块。我在 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.contenttypes',

# everything below here is optional

)

TENANT_APPS = (
'django.contrib.contenttypes',

# your tenant-specific apps
# 'myapp.hotels',
# 'myapp.houses',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',

)

INSTALLED_APPS = [
'tenant_schemas',
'customers',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
]

TENANT_MODEL = "customers.Client"

MIDDLEWARE = [
'tenant_schemas.middleware.TenantMiddleware',
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'sitemanager.urls'
PUBLIC_SCHEMA_URLCONF = 'sitemanager.urls_public'

尝试打开 http://localhost:8000/admin 时出现错误:

DoesNotExist at /admin/login/
Site matching query does not exist.
Request Method: GET
Request URL: http://localhost:8000/admin/login/?next=/admin/
Django Version: 2.1.2
Exception Type: DoesNotExist
Exception Value:
Site matching query does not exist.

我的urls.py:

from django.contrib import admin
from django.urls import path

urlpatterns = [
path('admin/', admin.site.urls),
]

我在配置中缺少什么?

最佳答案

添加 PUBLIC_SCHEMA_NAME = 'public' 可以解决问题。

关于python - django-tenant-schema 为所有租户启用管理模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52762102/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com