38086-vm/core/migrations/0031_create_superuser.py
2026-02-09 17:33:09 +00:00

20 lines
593 B
Python

from django.db import migrations
from django.contrib.auth.models import User
def create_superuser(apps, schema_editor):
if not User.objects.filter(username='admin').exists():
User.objects.create_superuser('admin', 'admin@example.com', 'admin12345')
def remove_superuser(apps, schema_editor):
User.objects.filter(username='admin').delete()
class Migration(migrations.Migration):
dependencies = [
('core', '0030_salepayment_created_at_purchasepayment_created_at'),
]
operations = [
migrations.RunPython(create_superuser, remove_superuser),
]