title: Add a boolean field if a row exists in another table?
body: <p>I have two tables called <code>Post</code> and <code>Reply</code>. The users can create just one <code>Response</code> for each <code>Post</code>. The models look like this:</p>
  
  <pre><code>class Post(models.Model):
      name = models.CharField(max_length = 100)
  
  class Reply(models.Model):
      post = models.ForeignKey(Post, related_name = 'replies')
  </code></pre>
  
  <p>Now, I have a view that returns the posts, like this:</p>
  
  <pre><code>class PostList(generics.ListAPIView):
      permission_classes = (permissions.IsAuthenticated,)
      queryset = Post.objects.all()
      serializer_class = PostSerializer
  </code></pre>
  
  <p>And a serializer for the posts:</p>
  
  <pre><code>class PostSerializer(serializers.ModelSerializer):
      class Meta:
          fields = ('id', 'name')
  </code></pre>
  
  <p>The results of this view look like this:</p>
  
  <pre><code>[
      {
          "id": "1",
          "name": "The first post"
      },
      {
          "id": "2",
          "name": "The second post"
      }
  ]
  </code></pre>
  
  <p>Now, to the actual problem in question: I'd like to have a boolean field in the results that'd be <code>true</code> if the user has replied to the post, and <code>false</code> if they hasn't. Basically, the result for a situation where the current user has replied to the first post but not the second post would look like this:</p>
  
  <pre><code>[
      {
          "id": "1",
          "name": "The first post",
          "replied": "true"
      },
      {
          "id": "2",
          "name": "The second post",
          "replied": "false"
      }
  ]
  </code></pre>
  
  <p>How do I achieve this? I have a hunch that this should be implemented in the serializer somehow, but I don't know how I'd do that.</p>
  
  <p>Thanks in advance for all your help!</p>