django-autocomplete-light
django-autocomplete-light copied to clipboard
No way to conveniently display custom labels using Select2ListView
There is a very convenient method when I use Select2QuerySetView (using get_result_label), why isn't there a similar thing in ListViews ? There is only a way to change the value, but I can't find any to change the displayed labels, please let me know if I missed something.
Did you figure this out? Would you like to make a pull request?
This is what I did
class ColorAutocompleteView(autocomplete.Select2ListView):
def get_result_with_label(self, choice):
new_choice = (choice[0],
format_html('<div style="background-color:{}; width: 100%; height:100%;">{}</div>',
choice[0], choice[1]))
return new_choice
def get_list(self):
return [self.get_result_with_label(choice) for choice in TailwindColors.choices]