accounts app redirections

This commit is contained in:
2021-10-27 10:49:54 +03:00
parent bef1e8a9f1
commit 7da2982b54
6 changed files with 26 additions and 32 deletions

View File

@@ -0,0 +1,19 @@
from django.core.management.base import BaseCommand
from server.apps.accounts.models import CustomUser
class Command(BaseCommand):
def handle(self, *args, **options):
if not CustomUser.objects.filter(username='admin').exists():
username = 'admin'
email = 'admin@admin.ru'
password = 'admin'
admin = CustomUser.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')