Skip to content

Commit

Permalink
Fix N+1 on the ticket finder
Browse files Browse the repository at this point in the history
  • Loading branch information
DragoonAethis committed Feb 22, 2024
1 parent 5bc2168 commit 378b0e9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion events/views/crew/accreditation.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ def form_valid(self, form):
query |= Q(**{f"{field}__icontains": text_query})

try:
tickets = list(Ticket.objects.filter(event_id=self.event.id).filter(query))
tickets = list(
Ticket.objects.filter(event_id=self.event.id)
.filter(query)
.prefetch_related("event", "type", "type__event")
)
if len(tickets) == 0:
messages.error(self.request, _("No tickets found."))
return redirect("crew_index", self.event.slug)
Expand Down

0 comments on commit 378b0e9

Please sign in to comment.