Нет описания

create_superuser.py 429B

1234567891011
  1. from django.core.management.base import BaseCommand
  2. from django.contrib.auth.models import User
  3. class Command(BaseCommand):
  4. help = 'Creates a superuser.'
  5. def handle(self, *args, **options):
  6. if not User.objects.filter(username='admin').exists():
  7. User.objects.create_superuser('admin', 'admin@example.com', 'admin')
  8. self.stdout.write(self.style.SUCCESS('Successfully created superuser.'))