parameters: (parser, token)
docstring: Retrieves a list of ``Tag`` objects associated with a given model
      and stores them in a context variable.
  
      Usage::
  
         {% tags_for_model [model] as [varname] %}
  
      The model is specified in ``[appname].[modelname]`` format.
  
      Extended usage::
  
         {% tags_for_model [model] as [varname] with counts %}
  
      If specified - by providing extra ``with counts`` arguments - adds
      a ``count`` attribute to each tag containing the number of
      instances of the given model which have been tagged with it.
  
      Examples::
  
         {% tags_for_model products.Widget as widget_tags %}
         {% tags_for_model products.Widget as widget_tags with counts %}
docstring_summary: Retrieves a list of ``Tag`` objects associated with a given model
      and stores them in a context variable.
docstring_tokens: Retrieves a list of Tag objects associated with a given model and stores them in a context variable .
function: def do_tags_for_model(parser, token):
      """
      Retrieves a list of ``Tag`` objects associated with a given model
      and stores them in a context variable.
  
      Usage::
  
         {% tags_for_model [model] as [varname] %}
  
      The model is specified in ``[appname].[modelname]`` format.
  
      Extended usage::
  
         {% tags_for_model [model] as [varname] with counts %}
  
      If specified - by providing extra ``with counts`` arguments - adds
      a ``count`` attribute to each tag containing the number of
      instances of the given model which have been tagged with it.
  
      Examples::
  
         {% tags_for_model products.Widget as widget_tags %}
         {% tags_for_model products.Widget as widget_tags with counts %}
  
      """
      bits = token.contents.split()
      len_bits = len(bits)
      if len_bits not in (4, 6):
          raise TemplateSyntaxError(_('%s tag requires either three or five arguments') % bits[0])
      if bits[2] != 'as':
          raise TemplateSyntaxError(_("second argument to %s tag must be 'as'") % bits[0])
      if len_bits == 6:
          if bits[4] != 'with':
              raise TemplateSyntaxError(_("if given, fourth argument to %s tag must be 'with'") % bits[0])
          if bits[5] != 'counts':
              raise TemplateSyntaxError(_("if given, fifth argument to %s tag must be 'counts'") % bits[0])
      if len_bits == 4:
          return TagsForModelNode(bits[1], bits[3], counts=False)
      else:
          return TagsForModelNode(bits[1], bits[3], counts=True)
function_tokens: def do_tags_for_model ( parser , token ) : bits = token . contents . split ( ) len_bits = len ( bits ) if len_bits not in ( 4 , 6 ) : raise TemplateSyntaxError ( _ ( '%s tag requires either three or five arguments' ) % bits [ 0 ] ) if bits [ 2 ] != 'as' : raise TemplateSyntaxError ( _ ( "second argument to %s tag must be 'as'" ) % bits [ 0 ] ) if len_bits == 6 : if bits [ 4 ] != 'with' : raise TemplateSyntaxError ( _ ( "if given, fourth argument to %s tag must be 'with'" ) % bits [ 0 ] ) if bits [ 5 ] != 'counts' : raise TemplateSyntaxError ( _ ( "if given, fifth argument to %s tag must be 'counts'" ) % bits [ 0 ] ) if len_bits == 4 : return TagsForModelNode ( bits [ 1 ] , bits [ 3 ] , counts = False ) else : return TagsForModelNode ( bits [ 1 ] , bits [ 3 ] , counts = True )