i want to make a html view with some data from the DB. i want to use the render function from the views.py and show it in the html. the code will look like this as example.
views.py
def progress_proyek_detail(request):
bobot_per_week_data = BobotperWeek.objects.all()
progress_data = ProgressProyek.objects.all()
data = {
'progress_data': progress_data,
'bobot_per_week_data': bobot_per_week_data,
}
return render(request, 'progress_proyek_detail.html', data)
and for the html it will be like this
<!-- progress_proyek_detail.html -->
<!DOCTYPE html>
<html>
<head>
<title>Progress Proyek Detail</title>
</head>
<body>
<h1>Progress Proyek Data</h1>
<table border="1">
<thead>
<tr>
<th>Nomor</th>
<th>Pekerjaan</th>
<th>Bobot (%)</th>
{% for bobot_per_week in bobot_per_week_data %}
<th>{{ bobot_per_week.tanggal }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Pekerjaan Persiapan</td>
<td>{{ progress_data.0.bobot_pekerjaan_persiapan }}</td>
</tr>
<tr>
<td>2</td>
<td>Pekerjaan Galian Tanah</td>
<td>{{ progress_data.0.bobot_pekerjaan_galian_tanah }}</td>
</tr>
<tr>
<td>3</td>
<td>Pekerjaan Fondasi</td>
<td>{{ progress_data.0.bobot_pekerjaan_fondasi }}</td>
</tr>
<tr>
<td>4</td>
<td>Pekerjaan Cor Beton Pile Cap</td>
<td>{{ progress_data.0.bobot_pekerjaan_cor_beton_pile_cap }}</td>
</tr>
<tr>
<td>5</td>
<td>Pekerjaan Cor Beton Slug</td>
<td>{{ progress_data.0.bobot_pekerjaan_cor_beton_slug }}</td>
</tr>
<tr>
<td>6</td>
<td>Pekerjaan Pelat Beton Lantai</td>
<td>{{ progress_data.0.bobot_pekerjaan_pelat_beton_lantai }}</td>
</tr>
<tr>
<td>7</td>
<td>Pekerjaan Pelat Bawah Retaining Wall</td>
<td>{{ progress_data.0.bobot_pekerjaan_pelat_bawah }}</td>
</tr>
<tr>
<td>8</td>
<td>Pekerjaan Dinding</td>
<td>{{ progress_data.0.bobot_pekerjaan_dinding }}</td>
</tr>
<tr>
<td>9</td>
<td>Pekerjaan Konstruksi Baja</td>
<td>{{ progress_data.0.bobot_pekerjaan_konstruksi_baja }}</td>
</tr>
<tr>
<td>10</td>
<td>Pekerjaan Penutup Atap dan Lain-lain</td>
<td>{{ progress_data.0.bobot_pekerjaan_penutup }}</td>
</tr>
<tr>
<td colspan="3">BOBOT RENCANA</td>
</tr>
<tr>
<td colspan="3">KUMULATIF BOBOT RENCANA</td>
</tr>
<tr>
<td colspan="3">BOBOT AKTUAL REALISASI</td>
</tr>
<tr>
<td colspan="3">KUMULATIF BOBOT AKTUAL REALISASI</td>
</tr>
<tr>
<td colspan="3">NILAI DEVIASI</td>
</tr>
</tbody>
</table>
</body>
</html>
is it a good choice to use? i will add some more data fetching later in this views.py