From bba0fc4934f8f45eaa702cdfbeb9ab33defbfcbf Mon Sep 17 00:00:00 2001 From: Todd Dembrey <todd.dembrey@torchbox.com> Date: Fri, 31 Aug 2018 13:23:55 +0100 Subject: [PATCH] Get the projects in a more efficient manner --- opentech/public/projects/models.py | 2 +- opentech/public/utils/templates/utils/listing_index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/opentech/public/projects/models.py b/opentech/public/projects/models.py index b1dcc1157..eacc416ec 100644 --- a/opentech/public/projects/models.py +++ b/opentech/public/projects/models.py @@ -156,7 +156,7 @@ class ProjectIndexPage(BasePage): def get_context(self, request, *args, **kwargs): context = super().get_context(request, *args, **kwargs) - subpages = self.get_children().live() + subpages = ProjectPage.objects.descendant_of(self).live().public().select_related('icon') per_page = settings.DEFAULT_PER_PAGE page_number = request.GET.get('page') paginator = Paginator(subpages, per_page) diff --git a/opentech/public/utils/templates/utils/listing_index.html b/opentech/public/utils/templates/utils/listing_index.html index 989d2a315..241139062 100644 --- a/opentech/public/utils/templates/utils/listing_index.html +++ b/opentech/public/utils/templates/utils/listing_index.html @@ -10,7 +10,7 @@ <div class="wrapper wrapper--listings"> {% if subpages.object_list.exists %} - {% for subpage in subpages.object_list.specific %} + {% for subpage in subpages.object_list %} <a class="listing" href="{% pageurl subpage %}"> {% if subpage.icon %} -- GitLab