def filter_choices_to_render(self, selected_choices):
        """Overwrite self.choices to exclude unselected values."""
        if len(selected_choices) == 1 and not selected_choices[0]:
            selected_choices = []

        ctype_models = {}

        for choice in selected_choices:
            ctype_pk, model_pk = choice.split('-')
            ctype_pk = int(ctype_pk)
            ctype_models.setdefault(ctype_pk, [])
            ctype_models[ctype_pk].append(model_pk)

        self.choices = []
        ctype = ContentType.objects.get_for_id
        for ctype_pk, ids in ctype_models.items():
            results = ctype(ctype_pk).model_class().objects.filter(pk__in=ids)

            self.choices += [
                ('%s-%s' % (ctype_pk, r.pk), six.text_type(r))
                for r in results
            ]
dataset/ETHPy150Open yourlabs/django-autocomplete-light/src/dal_queryset_sequence/widgets.py/QuerySetSequenceSelectMixin.filter_choices_to_render/original