Fewer requests on spectacles and participants list views

This commit is contained in:
Aurélien Delobelle 2017-04-08 13:01:05 +02:00
parent 93a3a9af2c
commit 15d2faf8e1

View file

@ -622,7 +622,10 @@ def revente_shotgun(request, tirage_id):
def spectacle(request, tirage_id, spectacle_id):
tirage = get_object_or_404(Tirage, id=tirage_id)
spectacle = get_object_or_404(Spectacle, id=spectacle_id, tirage=tirage)
attributions = spectacle.attribues.all()
attributions = (
spectacle.attribues
.select_related('participant', 'participant__user')
)
participants = {}
for attrib in attributions:
participant = attrib.participant
@ -651,7 +654,10 @@ class SpectacleListView(ListView):
def get_queryset(self):
self.tirage = get_object_or_404(Tirage, id=self.kwargs['tirage_id'])
categories = self.tirage.spectacle_set.all()
categories = (
self.tirage.spectacle_set
.select_related('location')
)
return categories
def get_context_data(self, **kwargs):