🐛 Createsuperuser in single asyncio task
This commit is contained in:
parent
4a5bafd889
commit
715b7a030a
1 changed files with 10 additions and 3 deletions
|
|
@ -165,6 +165,13 @@ def createsuperuser(root: str = "."):
|
||||||
)
|
)
|
||||||
user.set_email(email)
|
user.set_email(email)
|
||||||
user.set_password(password1)
|
user.set_password(password1)
|
||||||
asyncio.run(project.init_orm())
|
|
||||||
asyncio.run(user.save())
|
async def _run():
|
||||||
asyncio.run(project.close_orm())
|
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())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue