diff --git a/opentech/public/news/models.py b/opentech/public/news/models.py index d57f6f118794111b7faaf5d3be171c59b4fa53b2..dbb645c7657cfc354b8d50d01919bfd2834658df 100644 --- a/opentech/public/news/models.py +++ b/opentech/public/news/models.py @@ -131,7 +131,10 @@ class NewsIndex(BasePage): def get_context(self, request, *args, **kwargs): news = NewsPage.objects.live().public().descendant_of(self).annotate( date=Coalesce('publication_date', 'first_published_at') - ).order_by('-date') + ).order_by('-date').prefetch_related( + 'news_types__news_type', + 'authors__author', + ) if request.GET.get('news_type'): news = news.filter(news_types__news_type=request.GET.get('news_type')) diff --git a/opentech/public/people/models.py b/opentech/public/people/models.py index dd43e3b57fbfd4637369b79a5c5cccfdc32a6826..ceea639ad1d73b2d61a81039941459570639140d 100644 --- a/opentech/public/people/models.py +++ b/opentech/public/people/models.py @@ -172,7 +172,13 @@ class PersonIndexPage(BasePage): parent_page_types = ['standardpages.IndexPage'] def get_context(self, request, *args, **kwargs): - people = PersonPage.objects.live().public().descendant_of(self).order_by('title') + people = PersonPage.objects.live().public().descendant_of(self).order_by( + 'title', + ).select_related( + 'photo', + ).prefetch_related( + 'person_types__person_type', + ) if request.GET.get('person_type'): people = people.filter(person_types__person_type=request.GET.get('person_type'))