diff --git a/netbox/extras/ui/panels.py b/netbox/extras/ui/panels.py index d2bee80f2..23a3da37b 100644 --- a/netbox/extras/ui/panels.py +++ b/netbox/extras/ui/panels.py @@ -64,12 +64,8 @@ class CustomFieldsPanel(panels.ObjectPanel): 'custom_fields': obj.get_custom_fields_by_group(), } - def render(self, context): - ctx = self.get_context(context) - # Hide the panel if no custom fields exist - if not ctx['custom_fields']: - return '' - return super().render(context) + def should_render(self, context): + return bool(context['custom_fields']) class ImageAttachmentsPanel(panels.ObjectsTablePanel): diff --git a/netbox/netbox/ui/panels.py b/netbox/netbox/ui/panels.py index f084b2588..3ee49b6a2 100644 --- a/netbox/netbox/ui/panels.py +++ b/netbox/netbox/ui/panels.py @@ -89,9 +89,9 @@ class Panel: Parameters: context (dict): The template context """ - if not self.should_render(context): - return '' ctx = self.get_context(context) + if not self.should_render(ctx): + return '' return render_to_string(self.template_name, ctx, request=ctx.get('request')) @@ -427,4 +427,4 @@ class ContextTablePanel(ObjectPanel): } def should_render(self, context): - return self._resolve_table(context) is not None + return context.get('table') is not None