Closed sandeepbalagopal09 closed 4 years ago
Hi @sandeepimpressads,
thanks for reaching out. If I understand you correctly, you will need to set the search_fields
. I added them to your code example, see below:
class SearchArticleForm(forms.ModelForm):
categories = forms.ModelMultipleChoiceField(
queryset=ArticleCategory.objects.all(),
widget=Select2MultipleWidget(search_fields=['field_name___istartswith']),
)
Best -Joe
thanks @codingjoe it worked.
Goal I am using Select2MultipleWidget, one thing is fine except my client want to search based on
istartswith
query. Currently the search works by the__str__
of the object it seems. I want to change it tofield_name___istartswith
.Code Snippet