[Answered ]-Django Rest Framework – IntegrityError: null value in column "user_id" violates not-null constraint

2👍

I think what you want instead after you make your user is this

team = UniservedTeam.objects.create(user=user,Role=['Vendor Co-ordinator'],ContactNumber='862339798167')

0👍

Try this,

team = UniservedTeam.objects.create(user__id=user.id, Role=['Vendor Co-ordinator'],ContactNumber='862339798167')

Leave a comment