From 715b7a030a0e0fc4c834a347a3a33629f65b2314 Mon Sep 17 00:00:00 2001 From: Brian Wiborg Date: Sun, 26 Oct 2025 21:47:03 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Createsuperuser=20in=20single=20?= =?UTF-8?q?asyncio=20task?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ohmyapi/cli.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ohmyapi/cli.py b/src/ohmyapi/cli.py index a530424..fd41084 100644 --- a/src/ohmyapi/cli.py +++ b/src/ohmyapi/cli.py @@ -165,6 +165,13 @@ def createsuperuser(root: str = "."): ) user.set_email(email) user.set_password(password1) - asyncio.run(project.init_orm()) - asyncio.run(user.save()) - asyncio.run(project.close_orm()) + + async def _run(): + await project.init_orm() + user = ohmyapi_auth.models.User(username=username, is_staff=True, is_admin=True) + user.set_email(email) + user.set_password(password1) + await user.save() + await project.close_orm() + + asyncio.run(_run())