title: Django - displaying each individual user's comment count on a post_detail template
body: <p>I have my comments set up where users can review blog posts and have those reviews show up in the <code>post_detail.html</code> template. I would like to display the total number of comments for every user, right next to their comments (in any post).</p>
  
  <p>For example, I'd like it to say <code>user 1: 4 comments</code>, and so on, for each user. If <code>user 1</code> has left 4 comments on 4 different posts, all 4 posts should display <code>user 1: 4 comments</code>.</p>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>class UserProfile(models.Model):
      user = models.OneToOneField(User, related_name='profile')
  
  ...
  
  def user_rating_count(self):
      user_ratings = Comment.objects.filter(user=2).count()
      return user_ratings
  
  ...
  
  class Comment(models.Model):
      post = models.ForeignKey(Post, related_name="comments")
      user = models.ForeignKey(User, related_name="usernamee")
      ...
      review_count = models.IntegerField(default=0)
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>@login_required
  def add_comment(request, slug):
      post = get_object_or_404(Post, slug=slug)
  
      if request.method == 'POST':
          form = CommentForm(request.POST)
          if form.is_valid():
              comment = form.save(commit=False)
              comment.post = post # Makes the post linked to the comment
              comment.user = request.user # Makes the user linked to the comment
              comment.email = request.user.email
              comment.picture = request.user.profile.profile_image_url()
              comment.review_count = request.user.profile.user_rating_count()
              comment.save()
  
              return redirect('blog:post_detail', slug=post.slug)
      else:
          form = CommentForm()
  
      template = "blog/post/add_comment.html"
      context = {'form': form}
      return render(request, template, context)
  </code></pre>
  
  <p><strong>post_detail.html</strong></p>
  
  <pre><code>...
  {% for comment in post.comments.all %}
      {{ comment.review_count }}
  {% endfor %}
  ...
  </code></pre>
  
  <p>I've been trying to accomplish this through my model's <code>user_rating_count</code> method, but I can only manually select <code>user=1</code> or <code>user=2</code>, which works, but it isn't dynamic. I'm trying to retrieve the user that left the comment.</p>