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()
        try:
            user.objects.get(username='admin', is_superuser=True)
        except user.DoesNotExist:
            user.objects.create_superuser('admin', 'admin@myproject.com', 'password')
        else:
            self.stdout.write('Superuser is still alive')

