Files
backend/apps/shared/management/commands/createadmin.py
A'zamov Samandar 0229a0595c
Some checks failed
Deploy Django Application to Server / deploy (push) Failing after 19s
Telegram Notifications / Telegram Gate (push) Failing after 5s
gealogiuya
2026-02-27 14:56:23 +05:00

26 lines
990 B
Python

from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand
class Command(BaseCommand):
def handle(self, *args, **options):
user = get_user_model()
self.create_superuser(user, "jahongir", "jahongirhakimjonov@gmail.com", "1253")
self.create_superuser(
user, "Jahongir", "jahongirhakimjonov@gmail.com", "20030307mart"
)
self.create_superuser(
user, "998330078587", "jahongirhakimjonov@gmail.com", "20030307mart"
)
def create_superuser(self, user, username, email, password):
if not user.objects.filter(username=username).exists():
user.objects.create_superuser(username, email, password)
self.stdout.write(
self.style.SUCCESS(f"Superuser {username} created successfully.")
)
else:
self.stdout.write(
self.style.SUCCESS(f"Superuser {username} already exists.")
)