From 1b73b033a77bbe98a088f47722fa45afee48eafa Mon Sep 17 00:00:00 2001 From: Matt Westcott Date: Tue, 22 Mar 2022 22:07:33 +0000 Subject: [PATCH] Use cached_property for PanelGroup.BoundPanel.children --- wagtail/admin/panels.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wagtail/admin/panels.py b/wagtail/admin/panels.py index cc6e1662f2..89d743fa12 100644 --- a/wagtail/admin/panels.py +++ b/wagtail/admin/panels.py @@ -405,14 +405,16 @@ class PanelGroup(Panel): def __init__(self, panel, instance, request, form): super().__init__(panel=panel, instance=instance, request=request, form=form) - self.children = [ + @cached_property + def children(self): + return [ child.get_bound_panel( instance=self.instance, request=self.request, form=self.form ) for child in self.panel.children ] - @property + @cached_property def visible_children(self): return [child for child in self.children if child.is_shown()]