fix noscript schedule template, while here add a prefetch_related in the view to reduce number of sql lookups from 116 to 8 for bootstrap data

This commit is contained in:
Thomas Steen Rasmussen 2020-02-22 17:19:17 +01:00
parent 76fcfd7855
commit 27f3470f92
2 changed files with 6 additions and 4 deletions

View File

@ -29,7 +29,7 @@
<td>{{ instance.when.lower|date:"H:i" }}-{{ instance.when.upper|date:"H:i" }}</td>
<td>
<i class="fas fa-video{% if not instance.event.video_recording %}-slash{% endif %}"></i>
<a href="{% url 'program:event_detail' camp_slug=camp.slug slug=instance.event.slug %}">{{ instance.event.title }}</a>
<a href="{% url 'program:event_detail' camp_slug=camp.slug event_slug=instance.event.slug %}">{{ instance.event.title }}</a>
</td>
<td>{{ instance.location.name }}</td>
<td>{{ instance.event.event_type }}</td>

View File

@ -803,9 +803,11 @@ class NoScriptScheduleView(CampViewMixin, TemplateView):
def get_context_data(self, *args, **kwargs):
context = super().get_context_data(**kwargs)
context["eventinstances"] = models.EventInstance.objects.filter(
event__track__camp=self.camp
).order_by("when")
context["eventinstances"] = (
models.EventInstance.objects.filter(event__track__camp=self.camp)
.prefetch_related("location", "event__event_type")
.order_by("when")
)
return context