How to classify based on a column values from database in django

i wanted to classify some data from database and show it in a table this is how get the data

<tbody>
   <tr class="">
   {% for c in cluster %}
      <td>{% if c.hasil_klasifikasi == 'Banyak Terjangkit' %}{{ c.nama_penyakit }}{% endif %}</td>
      <td>{% if c.hasil_klasifikasi == 'Kurang Terjangkit' %}{{ c.nama_penyakit }}{% endif %}</td>                                
   </tr>            
   {% endfor %}
</tbody>

but the results dont looks right result on the table

any help would be very much appreciated, thanks

i was trying to classify the data in the table without blank cell like that

i want to get the data like this here

You should put the <tr> (the table-row), inside the loop:

<tbody>
    {% for c in cluster %}
    <tr class=""> <!-- 🖘 inside loop -->
        <td>{% if c.hasil_klasifikasi == 'Banyak Terjangkit' %}{{ c.nama_penyakit }}{% endif %}</td>
        <td>{% if c.hasil_klasifikasi == 'Kurang Terjangkit' %}{{ c.nama_penyakit }}{% endif %}</td>                                
    </tr>            
    {% endfor %}
</tbody>
Back to Top