Hilfe bei Einrichtung Django-Tenants

Django, Flask, Bottle, WSGI, CGI…
Antworten
KHerrmann
User
Beiträge: 1
Registriert: Freitag 26. März 2021, 16:36

Hallo liebe Community,

ich bin in der Python-Welt noch recht neu und unerfahren und hoffe hier nun Hilfe zu finden:

Ich scheitere an der Einrichtung von Django-Tenants. Ich habe die Tutorials befolgt, der Server läuft auch, aber beim Seitenaufruf kommt ein 404-Fehler: No tenant for hostname "127.0.0.1"
Die URL für die eingerichteten Mandanten funktioniert ebenfalls nicht. Weiß jemand Rat?

Hier mal meine settings.py:

DEBUG = True

ALLOWED_HOSTS = ['*']


# Application definition

SHARED_APPS = [
'django_tenants',
'clients',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

TENANT_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'kurse',
]

INSTALLED_APPS = list(SHARED_APPS) + [app for app in TENANT_APPS if app not in SHARED_APPS]

MIDDLEWARE = [
'django_tenants.middleware.main.TenantMainMiddleware',
'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 = 'kursverwaltung.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'kursverwaltung.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.1/r ... #databases

DATABASES = {
'default': {
'ENGINE': 'django_tenants.postgresql_backend',
'NAME': 'db_kursverwaltung',
'USER': 'postgres',
'PASSWORD': 'xxxxx',
'HOST': 'localhost',
'PORT': '5432',
}
}


# Password validation
# https://docs.djangoproject.com/en/3.1/r ... validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/h ... tic-files/

STATIC_URL = '/static/'

TENANT_MODEL = "clients.Client"
TENANT_DOMAIN_MODEL = "clients.Domain"

DATABASE_ROUTERS = (
'django_tenants.routers.TenantSyncRouter',
)
Antworten