Question: I am using Django REST Framework and facing a problem during inserting data into the child table. There are 2 models named Card and ContactName that have the following fields. The Card has a relation with ContactName via a foreign key field name card. models.py: class Card(models.Model): image = models.ImageField(upload_to='images', max_length=255, null=True, blank=True) filename = models.CharField(max_length=255, null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return self.filename class ContactName(models.Model): first_name = models.CharField(max_length=255, null=True, blank=True) last_name = models.CharField(max_length=255, null=True, blank=True) confidence = models.FloatField(default=0) card = models.ForeignKey(Card, on_delete=models.CASCADE, related_name='contact_name') created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self): return self.first_name  serializers.py file: class ContactNameSerializer(serializers.ModelSerializer): class Meta: model = ContactName fields = ['id', 'first_name', 'last_name', 'confidence', 'card', 'created_at', 'updated_at'] class CardSerializer(serializers.ModelSerializer): contact_name = ContactNameSerializer(many=True, read_only=True) class Meta: model = Card fields = ['id', 'image', 'filename', 'contact_name', 'created_at', 'updated_at']  In ViewSet once the card record is created, I also want to add the following ContactName JSON data into the child table, set the reference (card_id) as an id of that card, and return the newly added record in the response. e.g. [ { "first_name": "John", "last_name": "Doe", "confidence": 0.9 }, { "first_name": "Doe", "last_name": "John", "confidence": 0.5 } ]  views.py: class CardViewSet(viewsets.ModelViewSet): parser_classes = (MultiPartParser, FormParser) queryset = Card.objects.all() serializer_class = CardSerializer def create(self, request): cards_serializer = CardSerializer(data=request.data) if cards_serializer.is_valid(): cards_serializer.save() # insert the record into the child table and set the reference (card_id) as an id json = [ { "first_name": "John", "last_name": "Doe", "confidence": 0.9 }, { "first_name": "Doe", "last_name": "John", "confidence": 0.5 } ] return Response(cards_serializer.data, status=status.HTTP_201_CREATED) else: return Response(cards_serializer.errors, status=status.HTTP_400_BAD_REQUEST)  I really appreciate the help. The final response will be something like this: { "id": 10, "image": "/media/abc.jpg", "filename": "abc.jpg", "contact_names": [ { "id": 1, "first_name": "John", "last_name": "Doe", "confidence": 0.9, "card_id": 10 }, { "id": 2, "first_name": "Doe", "last_name": "John", "confidence": 0.5, "card_id": 10 } ] } 

Answer: Basically you can pass this data to your serializer by Including extra context and by overriding the create method as you are doing in your code: views.py class CardViewSet(viewsets.ModelViewSet): parser_classes = (MultiPartParser, FormParser) queryset = Card.objects.all() serializer_class = CardSerializer def create(self, request): json = [ { "first_name": "John", "last_name": "Doe", "confidence": 0.9 }, { "first_name": "Doe", "last_name": "John", "confidence": 0.5 } ] serializer = CardSerializer(data=request.data, context={'contacts': json}) if serializer.is_valid(raise_exception=True): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED)  Also, override the create method on CardSerializer, to first create the instance using the validated data and then use the extra context data to create ContactName objects and assign them to the new Card instance: serializers.py class ContactNameSerializer(serializers.ModelSerializer): class Meta: model = models.ContactName fields = ['id', 'first_name', 'last_name', 'confidence', 'card'] class CardSerializer(serializers.ModelSerializer): contact_name = ContactNameSerializer(many=True, read_only=True) class Meta: model = models.Card fields = ['id', 'image', 'filename', 'contact_name', 'created_at', 'updated_at'] def create(self, validated_data): instance = models.Card.objects.create(**validated_data) contacts = self.context.get('contacts', None) for contact in contacts: models.ContactName.objects.create(**contact, card=instance) return instance  A few notes: If you want card_id instead of card on the response data then change your field name (and update the serializer fields): class ContactName(models.Model): ... card_id = models.ForeignKey(Card...) ...  Alternatively, you can just override .to_representation, remove the key:pair and reinsert with the new key value. Also, I would change this relationship to a many-to-many in order to avoid ContactName duplicates in your database.