Ticket #4441: simplify-regroup.patch

File simplify-regroup.patch, 1016 bytes (added by (removed), 17 years ago)
  • django/template/defaulttags.py

    === modified file 'django/template/defaulttags.py'
     
    237237            return ''
    238238        output = [] # list of dictionaries in the format {'grouper': 'key', 'list': [list of contents]}
    239239        for obj in obj_list:
    240             grouper = self.expression.resolve(Context({'var': obj}), True)
     240            grouper = self.expression.resolve(obj, True)
    241241            if output and output[-1]['grouper'] == grouper:
    242242                output[-1]['list'].append(obj)
    243243            else:
     
    846846    if lastbits_reversed[1][::-1] != 'as':
    847847        raise TemplateSyntaxError, "next-to-last argument to 'regroup' tag must be 'as'"
    848848
    849     expression = parser.compile_filter('var.%s' % lastbits_reversed[2][::-1])
     849    expression = parser.compile_filter(lastbits_reversed[2][::-1])
    850850
    851851    var_name = lastbits_reversed[0][::-1]
    852852    return RegroupNode(target, expression, var_name)
Back to Top