diff options
| 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:58:21 +0100 |
| commit | fb28ce43f1fbc48011170c967697723f134a8e48 (patch) | |
| tree | 14819df32a925adfe21c5c835f21428773bec1f8 /ishtar_common/models_common.py | |
| parent | 2d530853fb3cd67b5572b404fd1eda1e20f803bd (diff) | |
| download | Ishtar-fb28ce43f1fbc48011170c967697723f134a8e48.tar.bz2 Ishtar-fb28ce43f1fbc48011170c967697723f134a8e48.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.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 9ce5b9e70..02e47ad56 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 |
