def render_option(self, selected_choices, option_value, option_label):
    option_value = force_text(option_value)
if option_value in selected_choices:
    selected_html = mark_safe(' selected="selected"')
if not self.allow_multiple_selected:
    selected_choices.remove(option_value)
else:
    selected_html = ''
filtertext = self.data_filter.get(option_value)
data_filtertext = 'data-filtertext="{filtertext}"'.format(filtertext=filtertext
    ) if filtertext else ''
return format_html('<option value="{0}"{1} {3}>{2}</option>', option_value,
    selected_html, force_text(option_label), mark_safe(data_filtertext))
Django: Как создать собственный виджет формы?