From ca45976b81462ee416ba9d3128a1a77d77425cae Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 4 Jan 2019 11:48:06 +0100 Subject: Select2widget: fix bad initialization --- ishtar_common/widgets.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'ishtar_common') diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 95b51ffb4..5853c9675 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -224,6 +224,10 @@ class Select2Base(Select2Media): else: attrs['style'] = "width: 370px" + if value: + if type(value) not in (list, tuple): + value = value.split(',') + options = "" if self.remote: options = """{ @@ -248,8 +252,6 @@ class Select2Base(Select2Media): }""" % self.remote if value: choices = [] - if type(value) not in (list, tuple): - value = value.split(',') for v in value: try: choices.append((v, self.model.objects.get(pk=v))) -- cgit v1.2.3