Commit ea6ab855 authored by fred's avatar fred
Browse files

performance: ditto when creating the grid

parent 22d5425a
......@@ -64,7 +64,6 @@ class Grid(TemplateView):
def get_context_data(self, **kwargs):
context = super(Grid, self).get_context_data(**kwargs)
schedules = Schedule.objects.all().order_by('datetime')
nb_lines = 2 * 24 # the cells are half hours
grid = []
......@@ -103,7 +102,7 @@ class Grid(TemplateView):
time_cell.time_label = '%02d:00-%02d:00' % (
nonstop[0], nonstop[1])
for schedule in Schedule.objects.all():
for schedule in Schedule.objects.select_related().order_by('datetime'):
row_start = schedule.datetime.hour * 2 + \
int(math.ceil(schedule.datetime.minute / 30))
day_no = schedule.get_weekday()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment