Currently i'm dealing with timetable project, have a list of schedule saved in database and i want to print them in a table where a schedule should be placed on a right place based on row(days) and columns (timeslots). i have tried to arrange schedule and it appear as follows: appearance of current tried schedule arrangement picture
The view used is as follows
def lecturerTimeTable(request):
lecname=Lecturer.objects.get(user=request.user.id)
context={
'schedule': TeachingTimetable.objects.filter(lecturer=lecname).order_by('meet_time'),#get lecturer
'program': Program.objects.all(),
'days': MeetingTime.objects.all().values('day').distinct(), #day
'slots': MeetingTime.objects.all().values('time').distinct(),#timeslot
'url_name':'class',#for active link
'lecturer':lecname,
'StarterPage':'Class-Timetable'# for head
}
return render(request,'users/class_timetable.html',context)
The template table is as follows
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th colspan="8"><center>{{lecturer}}</center</th>
</tr>
<tr>
<th></th>
{% for time in slots %}
<th class="time">{{time.time}}</th>{% comment %} timeslot from 07:00-09:00 to 17:00-21:00 {% endcomment %}
{% endfor %}
</tr>
</thead>
<tbody>
{% for day in days %}
<tr>
<th>{{day.day}} </th>
{% for lesson in schedule %}
{% if lesson.meet_day == day.day%}
{% if lesson.meet_time == '13:00 - 15:00' %}
<td>{{lesson.course}} <br>
{{lesson.lecturer}}<br>
{{lesson.venue}}<br>
{{lesson.meet_day}} {{lesson.meet_time}}</td>
{% comment %} {% endif %} {% endcomment %}
{% endif %}
{% endfor %}
</tr>
{% endfor %}
So i appreciate i will get help soon!
Thanks