OnlineJudge/utils/management/commands/initadmin.py
virusdefender b1793d29a2 new deploy
2017-06-11 01:20:05 +08:00

14 lines
472 B
Python

# coding=utf-8
from django.core.management.base import BaseCommand
from account.models import User, SUPER_ADMIN, UserProfile
class Command(BaseCommand):
def handle(self, *args, **options):
if User.objects.exists():
return
user = User.objects.create(username="root", real_name="root", email="root@oj.com", admin_type=SUPER_ADMIN)
user.set_password("password@root")
user.save()
UserProfile.objects.create(user=user)