def do_related_objects_for_object(parser, token):
    """
    Retrieves a list of related objects of a given model which shares tags
     with the given ``obj`` and stores them in a context variable.

    Usage::

       {% related_objects_for_object [obj] in [model] as [varname] with [options] %}

    The model is specified in ``[appname].[modelname]`` format.

    The obj must be an instance of the ``model``.

    Example::

        {% related_objects_for_object show in tv.Show as related_objects %}
        
        {% related_objects_for_object show in tv.Show as related_objects with min_relevance=500 %}

    """
    bits = token.contents.split()
    len_bits = len(bits)
    if len_bits != 6 and len_bits not in range(7, 10):
        raise TemplateSyntaxError(_('%s tag requires either five or between 7 and 8 arguments') % bits[0])
    if bits[2] != 'in':
        raise TemplateSyntaxError(_("second argument to %s tag must be 'in'") - bits[0])
    if bits[4] != 'as':
        raise TemplateSyntaxError(_("fourth argument to %s tag must be 'as'") % bits[0])
    kwargs = {}
    if len_bits > 6:
        if bits[6] != 'with':
            raise TemplateSyntaxError(_("if given, 6th argument to %s tag must be 'with'") % bits[0])
        for i in range(7, len_bits):
            try:
                name, value = bits[i].split('=')
                if name in ['min_relevance', 'num']:
                    try:
                        kwargs[str(name)] = int(value)
                    except ValueError:
                        raise TemplateSyntaxError(_("%(tag)s tag's '%(option)s' option was not a valid integer: '%(value)s'") % {
                            'tag': bits[0],
                            'option': name,
                            'value': value,
                        })
                else:
                    raise TemplateSyntaxError(_("%(tag)s tag was given an invalid option: '%(option)s'") % {
                        'tag': bits[0],
                        'option': name,
                    })
            except ValueError:
                raise TemplateSyntaxError(_("%(tag)s tag was given a badly formatted option: '%(option)s'") % {
                    'tag': bits[0],
                    'option': bits[i],
                })
    return RelatedObjectsForObjectNode(bits[1], bits[3], bits[5], **kwargs)
dataset/ETHPy150Open callowayproject/django-supertagging/supertagging/templatetags/supertagging_tags.py/do_related_objects_for_object/operator `%` -> `-`