mirror of
https://github.com/Balshgit/public.git
synced 2025-09-11 18:00:42 +03:00
20 lines
719 B
Python
20 lines
719 B
Python
from django.core.management.base import BaseCommand
|
|
from django.contrib.auth.models import User
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
def handle(self, *args, **options):
|
|
if not User.objects.filter(username='admin').exists():
|
|
username = 'admin'
|
|
email = 'admin@admin.ru'
|
|
password = 'admin'
|
|
admin = User.objects.create_superuser(username=username,
|
|
password=password,
|
|
email=email)
|
|
admin.is_active = True
|
|
admin.is_admin = True
|
|
admin.save()
|
|
else:
|
|
print('Admin accounts can only be initialized if no Accounts exist')
|