From f55d73b52aa7a7b51b0f815b6055ce850b6761f2 Mon Sep 17 00:00:00 2001 From: nearlynocturnalbeach Date: Mon, 2 Dec 2024 10:30:03 +0000 Subject: [PATCH] default admin username and email makes testing and setup much easier --- extra/management/commands/initadmin.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extra/management/commands/initadmin.py b/extra/management/commands/initadmin.py index b387df6..3a691d4 100644 --- a/extra/management/commands/initadmin.py +++ b/extra/management/commands/initadmin.py @@ -9,15 +9,15 @@ class Command(BaseCommand): def handle(self, *args, **options): if User.objects.count() == 0: - username = os.getenv("ADMIN_USERNAME") - email = os.getenv("ADMIN_EMAIL") + username = os.getenv("ADMIN_USERNAME", "admin") + email = os.getenv("ADMIN_EMAIL", "admin@localhost") password = self.generate_initial_password() print('Creating account for %s (%s)' % (username, email)) admin = User.objects.create_superuser(email=email, username=username, password=password) admin.is_active = True admin.is_admin = True admin.save() - + # from https://docs.python.org/3/library/secrets.html#recipes-and-best-practices def generate_initial_password(self): alpha = string.ascii_letters + string.digits