From a67d8ae106dc358d8ad5b5168c44f53cf8b7b476 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Thu, 6 Jul 2023 18:15:41 +0800 Subject: [PATCH] Fixed superuser being created as inactive user --- stude/accounts/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/stude/accounts/models.py b/stude/accounts/models.py index 02b18fc..4f33659 100644 --- a/stude/accounts/models.py +++ b/stude/accounts/models.py @@ -73,5 +73,10 @@ def create_superuser(sender, **kwargs): password = os.getenv('DJANGO_ADMIN_PASSWORD') if not User.objects.filter(username=username).exists(): - User.objects.create_superuser( - username, email, password) + # Create the superuser with is_active set to False + superuser = User.objects.create_superuser( + username=username, email=email, password=password) + + # Activate the superuser + superuser.is_active = True + superuser.save()