+ def __init__(self, queryset=None, *args, **kwargs):
+ super(SequencerSelect, self).__init__(*args, **kwargs)
+ self.queryset = queryset
+
+ def render_options(self, choices, selected_choices):
+ # Normalize to strings.
+ selected_choices = set([force_unicode(v) for v in selected_choices])
+ output = []
+ for option_value, option_label in chain(self.choices, choices):
+ if isinstance(option_label, (list, tuple)):
+ output.append(u'<optgroup label="%s">' % escape(force_unicode(option_value)))
+ for option in option_label:
+ output.append(self.render_option(selected_choices, *option))
+ output.append(u'</optgroup>')
+ else:
+ output.append(self.render_option(selected_choices, option_value, option_label))
+ return u'\n'.join(output)
+
+ # render_options blatently grabbed from 1.3.1 as the 1.2 version
+ # has render_option, which is what I needed to overload as a
+ # nested function in render_options
+ def render_options(self, choices, selected_choices):
+ # Normalize to strings.
+ selected_choices = set([force_unicode(v) for v in selected_choices])
+ output = []
+ for option_value, option_label in chain(self.choices, choices):
+ if isinstance(option_label, (list, tuple)):
+ output.append(u'<optgroup label="%s">' % escape(force_unicode(option_value)))
+ for option in option_label:
+ output.append(self.render_option(selected_choices, *option))
+ output.append(u'</optgroup>')
+ else:
+ output.append(self.render_option(selected_choices, option_value, option_label))
+ return u'\n'.join(output)
+
+