Concatenate lists in JINJA2

AFAIK you can’t do it using native Jinja2 templating. You’re better off creating a new combined iterable and passing that to your template, eg:

from itertools import chain

x = xrange(3)
y = xrange(3, 7)
z = chain(x, y) # pass this to your template
for i in z:
    print i

As per comments, you can explicitly convert the iterables into lists, and concatenate those:

{% for M in GRP1|list + GRP2|list %}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)