A query optimization in bda.views.catalogue
We only need to fetch shows identifiers here: FOO.filter(BAR__in=shows) which can be done using the `values_list` method
This commit is contained in:
parent
ff9cee5ffc
commit
9ec151e040
1 changed files with 3 additions and 2 deletions
|
@ -672,15 +672,16 @@ def catalogue(request, request_type):
|
|||
return HttpResponseBadRequest(
|
||||
"Bad format: int expected for `id`"
|
||||
)
|
||||
shows = tirage.spectacle_set.values_list("id", flat=True)
|
||||
categories = list(
|
||||
CategorieSpectacle.objects
|
||||
.filter(spectacle__in=tirage.spectacle_set.all())
|
||||
.filter(spectacle__in=shows)
|
||||
.distinct()
|
||||
.values('id', 'name')
|
||||
)
|
||||
locations = list(
|
||||
Salle.objects
|
||||
.filter(spectacle__in=tirage.spectacle_set.all())
|
||||
.filter(spectacle__in=shows)
|
||||
.distinct()
|
||||
.values('id', 'name')
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue