diff --git a/core/migrations/0031_create_superuser.py b/core/migrations/0031_create_superuser.py new file mode 100644 index 0000000..a64a53c --- /dev/null +++ b/core/migrations/0031_create_superuser.py @@ -0,0 +1,19 @@ +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), + ]