summaryrefslogtreecommitdiff
path: root/ishtar_common/widgets.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2017-03-29 20:15:43 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2017-03-29 20:15:43 +0200
commit98b781ff6bbced511fbe2291f661b524a260e05d (patch)
tree055d8c6ec436b1b5219cd09e32376cca52ad1768 /ishtar_common/widgets.py
parent88359ac26f56f3c6dae232bb9af529b9a35c758e (diff)
downloadIshtar-98b781ff6bbced511fbe2291f661b524a260e05d.tar.bz2
Ishtar-98b781ff6bbced511fbe2291f661b524a260e05d.zip
Widget: fix Select2Multiple initialization with string
Diffstat (limited to 'ishtar_common/widgets.py')
-rw-r--r--ishtar_common/widgets.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py
index f0e1dc775..94709406c 100644
--- a/ishtar_common/widgets.py
+++ b/ishtar_common/widgets.py
@@ -112,10 +112,12 @@ class Select2Multiple(forms.SelectMultiple):
}""" % 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)))
- except self.model.DoesNotExist:
+ except (self.model.DoesNotExist, ValueError):
# an old reference ? it should not happen
pass
html = super(Select2Multiple, self).render(name, value, attrs,