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