From 32b40a3bbb4ee01f87a9cf0fcac6f58ba55967a2 Mon Sep 17 00:00:00 2001 From: Marc 'risson' Schmitt Date: Thu, 28 Dec 2023 16:42:50 +0100 Subject: [PATCH] try with setting_changed signal Signed-off-by: Marc 'risson' Schmitt --- authentik/tenants/apps.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/authentik/tenants/apps.py b/authentik/tenants/apps.py index b3aef51a9..e8af0e361 100644 --- a/authentik/tenants/apps.py +++ b/authentik/tenants/apps.py @@ -1,4 +1,5 @@ """authentik tenants app""" +from django.core.signals import setting_changed from django.db import DEFAULT_DB_ALIAS from django.db.models.signals import post_migrate from django_tenants.utils import get_public_schema_name @@ -6,7 +7,7 @@ from django_tenants.utils import get_public_schema_name from authentik.blueprints.apps import ManagedAppConfig -def reconcile_default_tenant(*args, using=DEFAULT_DB_ALIAS, **kwargs): +def ensure_default_tenant(*args, using=DEFAULT_DB_ALIAS, **kwargs): """Make sure default tenant exists""" from django_tenants.utils import schema_context @@ -29,5 +30,6 @@ class AuthentikTenantsConfig(ManagedAppConfig): def reconcile_default_tenant(self): """Make sure default tenant exists, especially after a migration""" - reconcile_default_tenant() - post_migrate.connect(reconcile_default_tenant) + ensure_default_tenant() + post_migrate.connect(ensure_default_tenant) + setting_changed.connect(ensure_default_tenant)