def parse_related_tag(bits):
    if len(bits) < 6:
        raise template.TemplateSyntaxError, "{% related N [app_label.Model, ...] for object as var_name %}"

    if not bits[1].isdigit():
        raise template.TemplateSyntaxError, "Count must be an integer."

    if bits[-2] != 'as':
        raise template.TemplateSyntaxError, "Tag must end with as var_name "
    if bits[-4] != 'for':
        raise template.TemplateSyntaxError, "Tag must end with for object as var_name "

    if '.' in bits[2] or bits[2] == 'for':
        mod_index = 2
        finder = None
    else:
        mod_index = 3
        finder = bits[2]

    mods = []
    for m in bits[mod_index:-4]:
        if m == ',':
            continue
        if ',' in m:
            ms = m.split(',')
            for msm in ms:
                if not msm:
                    continue
                try:
                    mods.append(models.get_model(*msm.split('.')))
                except:
                    raise template.TemplateSyntaxError, "%r doesn't represent any model." % msm
        else:
            try:
                mods.append(models.get_model(*m.split('.')))
            except:
                raise template.TemplateSyntaxError, "%r doesn't represent any model." % m

    return bits[-3], int(bits[1]), bits[-1], mods, finder
dataset/ETHPy150Open ella/ella/ella/core/templatetags/related.py/parse_related_tag/original