From 97efd6f8bb4ea3bb1655d27f0eff160b34ac530f Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 9 Jun 2022 17:23:11 +0200 Subject: JSON fields: fix multi-value choices fields --- ishtar_common/models_common.py | 2 +- ishtar_common/widgets.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index ecbabcf7a..aae79c4fe 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -1097,7 +1097,7 @@ class JsonData(models.Model, CachedGen): c = [("", "")] c += [(v, v) for v in sorted(list(choices))] cache.set(cache_key, c, settings.CACHE_SMALLTIMEOUT) - return choices + return c class FixAssociated: diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 1f5a169ba..4852f4ceb 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -140,7 +140,7 @@ class Select2DynamicBase(Select2Media): value = value[0] values = value for va in values: - if va not in [key for key, va in choices]: + if va not in [key for key, v in choices]: choices.insert(1, (va, va)) self.choices = choices klass = attrs and attrs.get("class") or "" -- cgit v1.2.3