core: fix migrations when creating bootstrap token

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-06-17 10:09:56 +02:00
parent 6dff1f8e5e
commit 2298eb124f
2 changed files with 8 additions and 4 deletions

View File

@ -36,8 +36,10 @@ def fix_duplicates(apps: Apps, schema_editor: BaseDatabaseSchemaEditor):
def create_default_user_token(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 TokenIntents
from authentik.core.models import Token, TokenIntents, User
User = apps.get_model("authentik_core", "User")
Token = apps.get_model("authentik_core", "Token")
db_alias = schema_editor.connection.alias db_alias = schema_editor.connection.alias

View File

@ -7,8 +7,10 @@ from django.db.backends.base.schema import BaseDatabaseSchemaEditor
def create_default_user_token(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 TokenIntents
from authentik.core.models import Token, TokenIntents, User
User = apps.get_model("authentik_core", "User")
Token = apps.get_model("authentik_core", "Token")
db_alias = schema_editor.connection.alias db_alias = schema_editor.connection.alias