<reponame>FeiChaiCom/django-netdisk<filename>apps/contrib/sites/migrations/0004_init_superuser.py
from django.conf import settings
from django.db import migrations


def load_data(apps, schema_editor):
    """
    初始化管理员
    """
    from accounts.models import User

    if User.objects.exists():
        return

    for name in settings.INIT_ADMINS:
        User.objects.create_superuser(name, settings.DEFAULT_PASSWORD, role='ADMINISTRATOR')


class Migration(migrations.Migration):
    dependencies = [("sites", "0003_set_site_domain_and_name")]
    operations = [migrations.RunPython(load_data)]

from django.conf import settings
from django.db import migrations


def load_data(apps, schema_editor):
    """
    初始化管理员
    """
    from accounts.models import User

    if User.objects.exists():
        return

    for name in settings.INIT_ADMINS:
        User.objects.create_superuser(name, settings.DEFAULT_PASSWORD, role='ADMINISTRATOR')


class Migration(migrations.Migration):
    dependencies = [("sites", "0003_set_site_domain_and_name")]
    operations = [migrations.RunPython(load_data)]