Apply some low-hanging query count reduction
This commit is contained in:
parent
ff866fa052
commit
564f041b4a
3 changed files with 11 additions and 7 deletions
|
|
@ -5,8 +5,8 @@ from cms.plugin_pool import plugin_pool
|
|||
|
||||
from .models import (
|
||||
PLUGIN_TEMPLATES,
|
||||
GovernmentPlanSection,
|
||||
GovernmentPlansCMSPlugin,
|
||||
GovernmentPlanSection,
|
||||
GovernmentPlanSectionsCMSPlugin,
|
||||
)
|
||||
|
||||
|
|
@ -39,13 +39,15 @@ class GovernmentPlanSectionsPlugin(CMSPluginBase):
|
|||
def render(self, context, instance, placeholder):
|
||||
context = super().render(context, instance, placeholder)
|
||||
|
||||
if instance.government:
|
||||
if instance.government_id:
|
||||
sections = GovernmentPlanSection.objects.filter(
|
||||
government=instance.government
|
||||
government_id=instance.government_id
|
||||
)
|
||||
else:
|
||||
sections = GovernmentPlanSection.objects.all()
|
||||
|
||||
sections = sections.select_related("government")
|
||||
|
||||
context["sections"] = sections
|
||||
|
||||
return context
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue