From 052bf88c3d983ebb89352516aa1970e688d854b9 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 23 May 2020 19:12:55 +0200 Subject: [PATCH] core: create default user # Conflicts: # README.md --- passbook/core/migrations/0003_default_user.py | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 passbook/core/migrations/0003_default_user.py diff --git a/passbook/core/migrations/0003_default_user.py b/passbook/core/migrations/0003_default_user.py new file mode 100644 index 000000000..d0363c07c --- /dev/null +++ b/passbook/core/migrations/0003_default_user.py @@ -0,0 +1,28 @@ +# Generated by Django 3.0.6 on 2020-05-23 16:40 + +from django.apps.registry import Apps +from django.db import migrations +from django.db.backends.base.schema import BaseDatabaseSchemaEditor + + +def create_default_user(apps: Apps, schema_editor: BaseDatabaseSchemaEditor): + # User = apps.get_model("passbook_core", "User") + from passbook.core.models import User + + pbadmin = User.objects.create( + username="pbadmin", email="root@localhost", # password="pbadmin" + ) + pbadmin.set_password("pbadmin") # nosec + pbadmin.is_superuser = True + pbadmin.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ("passbook_core", "0002_auto_20200523_1133"), + ] + + operations = [ + migrations.RunPython(create_default_user), + ]