How to add data to the link I try to do so.

def create (self, validated_data) create_rig = Rig.objects.create(**validated_data) abs_user = AbsUser.objects.get(uid = pk) abs_user.rig = Rig.objects.filter(id = create_rig.id) abs_user.save() 

The following occurs; all associated rig entries are deleted and only one is written. How to implement adding related records?

    1 answer 1

    The point is that you are reassigning the connection to the rig and not adding a new one. Try calling the add method on the rig.

     create_rig = Rig.objects.create(**validated_data) abs_user = AbsUser.objects.get(uid = pk) abs_user.rig.add(Rig.objects.filter(id = create_rig.id)) abs_user.save()