summaryrefslogtreecommitdiff
path: root/ishtar_common/models_common.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2026-02-17 15:57:37 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2026-02-17 16:16:57 +0100
commit7946a926b4ce311ce217667d6ca32a1ad61e1e62 (patch)
treed47b645e0d3693341b266b2755dbfd31323bb94f /ishtar_common/models_common.py
parentdf3428679f82696252de98313f2d830c72aacc7f (diff)
downloadIshtar-7946a926b4ce311ce217667d6ca32a1ad61e1e62.tar.bz2
Ishtar-7946a926b4ce311ce217667d6ca32a1ad61e1e62.zip
⚡ templates: `list_filter` custom tag - improve performance for json_sections
Diffstat (limited to 'ishtar_common/models_common.py')
-rw-r--r--ishtar_common/models_common.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py
index a94eadb80..10c564024 100644
--- a/ishtar_common/models_common.py
+++ b/ishtar_common/models_common.py
@@ -1339,6 +1339,8 @@ class JsonData(models.Model, CachedGen):
@property
def json_sections(self):
+ if getattr(self, "__json_sections", None):
+ return self.__json_sections
sections = []
try:
content_type = ContentType.objects.get_for_model(self)
@@ -1382,6 +1384,12 @@ class JsonData(models.Model, CachedGen):
# if section name is identical it is the same
sections.append((section_name, []))
sections[-1][1].append((field.name, value))
+ # clean
+ sections = [
+ (label or "", section) for label, section in sections
+ if any(1 for __, value in section if value)
+ ]
+ self.__json_sections = sections
return sections
@classmethod