'Return a list of results usable by Select2.
It will render as a list of one <optgroup> per different content type
containing a list of one <option> per model.'

def get_results(self, context):

    groups = {}
    for result in context['object_list']:
        groups.setdefault(type(result), [])
        groups[type(result)].append(result)
    return [{'id': None, 'text': capfirst(self.get_model_name(model)), 'children': [{'id': self.get_result_value(result), 'text': six.text_type(result)} for result in results]} for (model, results) in groups.items()]
