=== modified file 'django/template/defaulttags.py'
|
|
|
|
| 4 | 4 | from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END |
| 5 | 5 | from django.template import get_library, Library, InvalidTemplateLibrary |
| 6 | 6 | from django.conf import settings |
| | 7 | from itertools import groupby |
| 7 | 8 | import sys |
| 8 | 9 | import re |
| 9 | 10 | |
| … |
… |
|
| 248 | 249 | if obj_list == None: # target_var wasn't found in context; fail silently |
| 249 | 250 | context[self.var_name] = [] |
| 250 | 251 | return '' |
| 251 | | output = [] # list of dictionaries in the format {'grouper': 'key', 'list': [list of contents]} |
| 252 | | for obj in obj_list: |
| 253 | | grouper = self.expression.resolve(obj, True) |
| 254 | | # TODO: Is this a sensible way to determine equality? |
| 255 | | if output and repr(output[-1]['grouper']) == repr(grouper): |
| 256 | | output[-1]['list'].append(obj) |
| 257 | | else: |
| 258 | | output.append({'grouper': grouper, 'list': [obj]}) |
| 259 | | context[self.var_name] = output |
| | 252 | # list of dictionaries in the format {'grouper': 'key', 'list': [list of contents]} |
| | 253 | context[self.var_name] = [{'grouper':key, 'list':list(val)} for key, val in |
| | 254 | groupby(obj_list, lambda v, f=self.expression.resolve: f(v, True))] |
| 260 | 255 | return '' |
| 261 | 256 | |
| 262 | 257 | def include_is_allowed(filepath): |