From 2298eb124f12f4ce3b7577887b4c2197c6b08b9b Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 17 Jun 2022 10:09:56 +0200 Subject: [PATCH] core: fix migrations when creating bootstrap token Signed-off-by: Jens Langhammer --- ...8_auto_20210330_1345_squashed_0028_alter_token_intent.py | 6 ++++-- authentik/core/migrations/0027_bootstrap_token.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/authentik/core/migrations/0018_auto_20210330_1345_squashed_0028_alter_token_intent.py b/authentik/core/migrations/0018_auto_20210330_1345_squashed_0028_alter_token_intent.py index 9909c54df..c24c37858 100644 --- a/authentik/core/migrations/0018_auto_20210330_1345_squashed_0028_alter_token_intent.py +++ b/authentik/core/migrations/0018_auto_20210330_1345_squashed_0028_alter_token_intent.py @@ -36,8 +36,10 @@ def fix_duplicates(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): def create_default_user_token(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): - # We have to use a direct import here, otherwise we get an object manager error - from authentik.core.models import Token, TokenIntents, User + from authentik.core.models import TokenIntents + + User = apps.get_model("authentik_core", "User") + Token = apps.get_model("authentik_core", "Token") db_alias = schema_editor.connection.alias diff --git a/authentik/core/migrations/0027_bootstrap_token.py b/authentik/core/migrations/0027_bootstrap_token.py index c5479f382..3b7054993 100644 --- a/authentik/core/migrations/0027_bootstrap_token.py +++ b/authentik/core/migrations/0027_bootstrap_token.py @@ -7,8 +7,10 @@ from django.db.backends.base.schema import BaseDatabaseSchemaEditor def create_default_user_token(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): - # We have to use a direct import here, otherwise we get an object manager error - from authentik.core.models import Token, TokenIntents, User + from authentik.core.models import TokenIntents + + User = apps.get_model("authentik_core", "User") + Token = apps.get_model("authentik_core", "Token") db_alias = schema_editor.connection.alias