Pass the value returned by get_context() to should_render()

This commit is contained in:
Jeremy Stretch
2026-04-02 12:09:24 -04:00
parent 33a3632792
commit 7042844930
2 changed files with 5 additions and 9 deletions

View File

@@ -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):

View File

@@ -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