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), ]