Why don't solve the chunking part in Python and then render the template appropriately?
Template:
<table>
{% for row in data %}
<tr>
{% for cell in row %}
<td>{{ cell }}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
Python part:
l = ['a',1,'b',2,'c',3,'d',4]
data = chunks(l)
print(data)
# prints [['a', 1, 'b', 2], ['c', 3, 'd', 4]]
where chunks
is coming from this answer.
Demo (all in the console without a Django project set):
In [1]: from django.conf import settings
In [2]: TEMPLATES = [{'BACKEND': 'django.template.backends.django.DjangoTemplates'}]
In [3]: settings.configure(TEMPLATES=TEMPLATES)
In [4]: from django.template import Template, Context
In [5]: import django
In [6]: django.setup()
In [7]: l = ['a',1,'b',2,'c',3,'d',4]
In [8]: data = chunks(l, n=4)
In [9] t = """
...: <table>
...: {% for row in data %}
...: <tr>
...: {% for cell in row %}
...: <td>{{ cell }}</td>
...: {% endfor %}
...: </tr>
...: {% endfor %}
...: </table>
...: """
In [10]: print(Template(t).render(Context({'data': data})))
<table>
<tr>
<td>a</td>
<td>1</td>
<td>b</td>
<td>2</td>
</tr>
<tr>
<td>c</td>
<td>3</td>
<td>d</td>
<td>4</td>
</tr>
</table>