title: How to make comments serializer work with post serializer in django rest framework.?
body: <p>I have this comment serializer which is not working. It is showing this error</p>
  <pre><code>{
  &quot;post&quot;: [
      &quot;This field is required.&quot;
  ]
  }
  </code></pre>
  <p>I am quite new to this, so can't really figure out how to properly link both the post and comment model.</p>
  <p>this is my serializer</p>
  <pre><code>class CommentCreateSerializer(serializers.ModelSerializer):
  content = serializers.CharField()
  post = PostSerializer(many=True)
  
  class Meta:
      model = Comment
      fields = ['id', 'post', 'content', 'reply']
  
  def create(self, validated_data):
      user = self.context['request'].user
      content = validated_data['content']
      reply = validated_data['reply']
      if reply:
          comment = Comment(user=user, content=content, reply=reply, post=post)
          comment.save()
      else:
          comment = Comment(user=user, content=content, post=post)
          comment.save()
      return validated_data
  </code></pre>
  <p>view</p>
  <pre><code>@api_view(['POST'])
  def comment_post_api(request, slug):
      try:
          post = get_object_or_404(Post, slug=slug)
      except Post.DoesNotExist:
          return Response(status=status.HTTP_404_NOT_FOUND)
      serializer = CommentCreateSerializer(post,data=request.data, context={'request':request})
      if serializer.is_valid():
          serializer.save()
          return Response(serializer.data, status=status.HTTP_201_CREATED)
      return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
  </code></pre>
  <p>urls</p>
  <pre><code> path('&lt;slug&gt;/comment/', views.comment_post_api, name='comment_post'),
  </code></pre>
  <p>Thanks</p>