@register.tag
def more_like_this(parser, token):
 bits = token.split_contents()
 if (not (len(bits) in (4, 6, 8))):
  raise template.TemplateSyntaxError((u"'%s' tag requires either 3, 5 or 7 arguments." % bits[0]))
 model = bits[1]
 if (bits[2] != u'as'):
  raise template.TemplateSyntaxError((u"'%s' tag's second argument should be 'as'." % bits[0]))
 varname = bits[3]
 limit = None
 for_types = None
 if (len(bits) == 6):
  if ((bits[4] != u'limit') and (bits[4] != u'for')):
   raise template.TemplateSyntaxError((u"'%s' tag's fourth argument should be either 'limit' or 'for'." % bits[0]))
  if (bits[4] == u'limit'):
   limit = bits[5]
  else:
   for_types = bits[5]
 if (len(bits) == 8):
  if (bits[4] != u'for'):
   raise template.TemplateSyntaxError((u"'%s' tag's fourth argument should be 'for'." % bits[0]))
  for_types = bits[5]
  if (bits[6] != u'limit'):
   raise template.TemplateSyntaxError((u"'%s' tag's sixth argument should be 'limit'." % bits[0]))
  limit = bits[7]
 return MoreLikeThisNode(model, varname, for_types, limit)

@ register . tag def more_like_this ( parser , token ) : bits = token . split_contents ( ) if ( not ( len ( bits ) in ( 4 , 6 , 8 ) ) ) : raise template . TemplateSyntaxError ( ( u"'%s' tag requires either 3, 5 or 7 arguments." % bits [ 0 ] ) ) model = bits [ 1 ] if ( bits [ 2 ] != u'as' ) : raise template . TemplateSyntaxError ( ( u"'%s' tag's second argument should be 'as'." % bits [ 0 ] ) ) varname = bits [ 3 ] limit = None for_types = None if ( len ( bits ) == 6 ) : if ( ( bits [ 4 ] != u'limit' ) and ( bits [ 4 ] != u'for' ) ) : raise template . TemplateSyntaxError ( ( u"'%s' tag's fourth argument should be either 'limit' or 'for'." % bits [ 0 ] ) ) if ( bits [ 4 ] == u'limit' ) : limit = bits [ 5 ] else : for_types = bits [ 5 ] if ( len ( bits ) == 8 ) : if ( bits [ 4 ] != u'for' ) : raise template . TemplateSyntaxError ( ( u"'%s' tag's fourth argument should be 'for'." % bits [ 0 ] ) ) for_types = bits [ 5 ] if ( bits [ 6 ] != u'limit' ) : raise template . TemplateSyntaxError ( ( u"'%s' tag's sixth argument should be 'limit'." % bits [ 0 ] ) ) limit = bits [ 7 ] return MoreLikeThisNode ( model , varname , for_types , limit )
fetches similar items from the search index to find content that is similar to the provided models content .