From 272c3381e1524a1f585c3eaa72c1f4ad75627507 Mon Sep 17 00:00:00 2001 From: Ross Date: Mon, 20 Oct 2025 13:08:06 +0100 Subject: [PATCH] Remove title from QuestionTable sequence and enhance render_stem method to include title in output --- sbas/tables.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sbas/tables.py b/sbas/tables.py index 78b1f106..f64c048a 100644 --- a/sbas/tables.py +++ b/sbas/tables.py @@ -39,7 +39,7 @@ class QuestionTable(tables.Table): "category", "author", ) - sequence = ("view","title", "stem", "answers")#, "exams") + sequence = ("view", "stem", "answers")#, "exams") attrs = {"class": "table row-selector"} def __init__(self, data=None, *args, **kwargs): @@ -51,7 +51,16 @@ class QuestionTable(tables.Table): **kwargs, ) - def render_stem(self, value): + def render_stem(self, value, record=None, **kwargs): + """Render the stem, optionally with a title from the record. + + Some versions of django-tables2 may call the render method without + passing a `record`; guard for that and fall back to rendering the + value only. + """ + title = getattr(record, "title", None) if record is not None else None + if title: + return format_html("
{}
{}", title, mark_safe(value)) return mark_safe(value)