diff --git a/authentik/blueprints/apps.py b/authentik/blueprints/apps.py index c90f9211e..beb85718e 100644 --- a/authentik/blueprints/apps.py +++ b/authentik/blueprints/apps.py @@ -59,7 +59,14 @@ class ManagedAppConfig(AppConfig): def reconcile(self) -> None: """reconcile ourselves""" - from django_tenants.utils import get_public_schema_name + from django_tenants.utils import get_public_schema_name, schema_context + + # Special case for the authentik_tenants app, as we need to create the default tenant + # before being able to use it + if self.label == "authentik_tenants": + with schema_context(get_public_schema_name()): + self._reconcile(self.RECONCILE_PREFIX) + return from authentik.tenants.models import Tenant