Hi,
I have a view that queries all data in my model (DrinkModel) and passes values to a table. I want to add a column to the table from a function that creates a list. If I pass the second list to the template i need a second iteration and effective just produce a column below the table.
My view:
def d_list(request):
drinks = models.DrinkModel.objects.all()
print(drinks)
duration_qs = duration_queryset()
return render(request, ‘list.html’, {‘drinks’: drinks, ‘duration_qs’: duration_qs})
My template:
{% for drink in drinks %}
<tr>
<td>{{ drink.pk }}</td>
<td><a href="{% url 'detail' drink.id %}"/> {{ drink.dn }}</td>
<td>{{ drink.ds }}</td>
<td>{{ drink.df }}</td>
<td>{{ drink.dt }}</td>
</tr>
{% endfor %}
{% for qs in duration_qs %}
<tr>
<td>{{ qs }}</td>
</tr>
{% endfor %}
Is there a way to iterate over duration_qs so that it lines up as the far right column of the first table?
Many thanks,
Brad