mirror of
https://github.com/house-of-vanity/OutFleet.git
synced 2025-07-06 17:14:07 +00:00
This commit is contained in:
17
vpn/management/commands/create_admin.py
Normal file
17
vpn/management/commands/create_admin.py
Normal file
@ -0,0 +1,17 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Create default admin user'
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
User = get_user_model()
|
||||
if not User.objects.filter(username='admin').exists():
|
||||
User.objects.create_superuser(
|
||||
username='admin',
|
||||
password='admin',
|
||||
email='admin@localhost'
|
||||
)
|
||||
self.stdout.write(self.style.SUCCESS('Admin user created'))
|
||||
else:
|
||||
self.stdout.write(self.style.WARNING('Admin user already exists'))
|
Reference in New Issue
Block a user