resources: reduce queries for langs in /partners/
@@ -37,8 +37,10 @@ class PartnersFilterView(ListView):
model = Partner
def get_queryset(self):
- qs = Partner.objects.select_related("coordinator", "logos").order_by(
- "company_name"
+ qs = (
+ Partner.objects.prefetch_related("languages")
+ .select_related("coordinator", "logos")
+ .order_by("company_name")
)
# The ordering here is useful primarily to people familiar with the
# English alphabet. :/
@@ -49,9 +51,11 @@ class PartnersFilterView(ListView):
"Because you are a staff member, this page may include "
"Partners who are not yet available to all users.",
)
- qs = Partner.even_not_available.select_related(
- "coordinator", "logos"
- ).order_by("company_name")
+ qs = (
+ Partner.even_not_available.prefetch_related("languages")
+ .select_related("coordinator", "logos")
+ .order_by("company_name")
+ )
return qs
