From bdc283675c0462e78f47059d2ce28cfabfb87433 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 13 Jun 2018 17:32:00 +0200 Subject: Simple selection widget and field for Select2 --- .../templates/ishtar/wizard/default_wizard.html | 2 +- ishtar_common/widgets.py | 38 +++++++++++++++++----- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/ishtar_common/templates/ishtar/wizard/default_wizard.html b/ishtar_common/templates/ishtar/wizard/default_wizard.html index 6707124f9..8d6b1c48e 100644 --- a/ishtar_common/templates/ishtar/wizard/default_wizard.html +++ b/ishtar_common/templates/ishtar/wizard/default_wizard.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% load i18n range table_form %} {% block extra_head %} -{{form.media}} +{{wizard.form.media}} {% endblock %} {% block content %} {% block wizard_head %} diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index d1f6e49d3..8788920af 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -181,14 +181,14 @@ class Select2DynamicField(forms.ChoiceField): return super(Select2DynamicField, self).to_python(value).strip() -class Select2Multiple(Select2Media, forms.SelectMultiple): +class Select2Base(Select2Media): def __init__(self, attrs=None, choices=(), remote=None, model=None, new=None, available=None): - super(Select2Multiple, self).__init__(attrs, choices) self.remote = remote self.available = available self.model = model self.new = new + super(Select2Base, self).__init__(attrs, choices) def get_q(self): q = self.model.objects @@ -273,7 +273,7 @@ class Select2Multiple(Select2Media, forms.SelectMultiple): u'+' % url_new - html += super(Select2Multiple, self).render(name, value, attrs) + html += super(Select2Base, self).render(name, value, attrs) html += new html += """