I don't use my form to ModelAdmin part, so to my mind it shouldn't solve my issue ?
Le mercredi 12 décembre 2018 15:55:30 UTC+1, valentin jungbluth a écrit : > > Hello guys, > > I would like to use *ModelMultipleChoiceField* with > *ModelSelect2MultipleWidget* in order to display a dropdown list with my > widget. > > If I write this : > > > publication_list = forms.ModelMultipleChoiceField(queryset=Publication. > objects.all().order_by('pub_id')) > > > It displays my queryset` but the design is not good and if I want to > select multiple objects, I have to highlight them. Then, I don't have > search bar. > > [image: search.png] > > > That's why I would like to write this : > > > publication_list = forms.ModelMultipleChoiceField( > queryset=Publication.objects.all().order_by('pub_id'), > label=_('Publication Choice'), > widget=ModelSelect2MultipleWidget( > model=Publication, > queryset=Publication.objects.all().order_by('pub_id'), > search_fields=['pub_id__icontains', 'title__icontains'], > ) > ) > > > > But with this code, this is the result : > > [image: search2.png] > > > It doesn't work and I would like to understand why ? > > The expected result should be something like that : > > [image: expected.png] > > Thank you by advance > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/47ae545a-fd79-4359-831c-7087ad029727%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.