[Fixed]-How do i print data from a database in column format?

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

Leave a comment