I was creating custom user in django for that i wrote following code in initial migration file but when we hit migrate command it gives TransactionManagementError
0001_initial.py
from django.db import migrations
from api.user.models import CustomUser
class Migration(migrations.Migration):
def seed_data(apps,schema_editor):
user = CustomUser(name = "abc",email = "abc@gmail.com",is_staff = True,is_superuser = True,
phone = "9874561230",gender = "Male")
user.set_password("12345")
user.save()
dependencies = [
]
operations = [
migrations.RunPython(seed_data),
]
error occcured:
django.db.transaction.TransactionManagementError: An error occurred in the current transaction. You
can't execute queries until the end of the 'atomic' block.