I have a Jinja2 template page which contains two separate {% for %}
loops. If neither of these loops contain any items, I want the page to redirect.
I'm trying to do something like this (pseudo-code):
loop1 = loop.length (in first loop)
loop2 = loop.length (in second loop)
if loop1 + loop2 == 0: redirect # (outside both loops)
Is this even possible? Is there a way to make the loop.length
variables available outside their respective loops?