Skip to content

Commit

Permalink
default admin username and email
Browse files Browse the repository at this point in the history
makes testing and setup much easier
  • Loading branch information
nearlynocturnalbeach committed Dec 2, 2024
1 parent 0c836b6 commit f55d73b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions extra/management/commands/initadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f55d73b

Please sign in to comment.