misc: update get_group template tag for Django 1.11 (#20935)

This commit is contained in:
Frédéric Péters 2018-01-01 12:32:51 +01:00
parent 50b3a2a3da
commit 754cf3292e
1 changed files with 4 additions and 1 deletions

View File

@ -211,7 +211,10 @@ def get(obj, key):
def get_group(group_list, group_name):
ret = []
for group in group_list:
if group['grouper'] == group_name:
if getattr(group, 'grouper', Ellipsis) == group_name:
# Django >= 1.11, namedtuple
ret.extend(group.list)
elif not hasattr(group, 'grouper') and group['grouper'] == group_name:
ret.extend(group['list'])
return ret