@register.inclusion_tag(u'generic/includes/comment.html', takes_context=True)
def comment_thread(context, parent):
 if (u'all_comments' not in context):
  comments = defaultdict(list)
  if ((u'request' in context) and context[u'request'].user.is_staff):
   comments_queryset = parent.comments.all()
  else:
   comments_queryset = parent.comments.visible()
  for comment in comments_queryset.select_related(u'user'):
   comments[comment.replied_to_id].append(comment)
  context[u'all_comments'] = comments
 parent_id = (parent.id if isinstance(parent, ThreadedComment) else None)
 try:
  replied_to = int(context[u'request'].POST[u'replied_to'])
 except KeyError:
  replied_to = 0
 context.update({u'comments_for_thread': context[u'all_comments'].get(parent_id, []), u'no_comments': ((parent_id is None) and (not context[u'all_comments'])), u'replied_to': replied_to})
 return context

@ register . inclusion_tag ( u'generic/includes/comment.html' , takes_context = True ) def comment_thread ( context , parent ) : if ( u'all_comments' not in context ) : comments = defaultdict ( list ) if ( ( u'request' in context ) and context [ u'request' ] . user . is_staff ) : comments_queryset = parent . comments . all ( ) else : comments_queryset = parent . comments . visible ( ) for comment in comments_queryset . select_related ( u'user' ) : comments [ comment . replied_to_id ] . append ( comment ) context [ u'all_comments' ] = comments parent_id = ( parent . id if isinstance ( parent , ThreadedComment ) else None ) try : replied_to = int ( context [ u'request' ] . POST [ u'replied_to' ] ) except KeyError : replied_to = 0 context . update ( { u'comments_for_thread' : context [ u'all_comments' ] . get ( parent_id , [ ] ) , u'no_comments' : ( ( parent_id is None ) and ( not context [ u'all_comments' ] ) ) , u'replied_to' : replied_to } ) return context
return a list of child comments for the given parent .