1π
β
To query all of the rows in a table:
ModelName.objects.all()
Then you can pass that to your view:
return render(request, 'music/compare.html', {
"rows": Question.objects.all()
})
And use the rows in your template:
<table>
<th>
<!-- Do your headers here -->
</th>
{% for row in rows %}
<tr>
<td>{{row.name}}</td>
<td>{{row.question1}}</td>
<td>{{row.question2}}</td>
...
</tr>
{% endfor %}
</table>
π€Jessie
Source:stackexchange.com