Okay, I've fixed it, but I think the error has arisen from some issue with my environment setup. I have nevertheless found a way around it. I replaced the following line:
user = User.objects.create_user(serialized.init_data['email'], serialized.init_data['username'], serialized.init_data['password'])
with:
user = get_user_model().objects.create_user(serialized.init_data['username'], email=serialized.init_data['email'], password=serialized.init_data['password'])
I obviously also had to import:
from django.contrib.auth import get_user_model
I haven't figured out why I needed to use get_user_model() instead of just being able to use my User object directly, but this solved my problem.