code: def count_discussions_handler(sender, **kwargs):
      
      if kwargs.get('instance') and kwargs.get('created'):
          # The signal is emitted by the comment creation,
          # so we do nothing, comment_was_posted is used instead.
          return
  
      comment = 'comment' in kwargs and kwargs['comment'] or kwargs['instance']
      entry = comment.content_object
  
      if isinstance(entry, Entry):
          entry.comment_count = entry.comments.count()
          entry.pingback_count = entry.pingbacks.count()
          entry.trackback_count = entry.trackbacks.count()
          entry.save(update_fields=[
              'comment_count', 'pingback_count', 'trackback_count'])
docs: Update the count of each type of discussion on an entry.