forked from applegrew/django-select2
-
-
Notifications
You must be signed in to change notification settings - Fork 57
Closed
Labels
questionFurther information is requestedFurther information is requested
Description
Goal
To get an entry "Select all" in the search.
Problem
I have around 20 million rows in table. The Admin wants to send mail to some specific or to all users. Now he may type a phrase to search for a user or he may want to send the mail to all users. If he wants to send mail to all the users it would just be sufficient for him to select "Select all" from the field.
Code Snippet
Please provide a code snippet of your problem.
class UsersWidget(s2forms.ModelSelect2MultipleWidget):
search_fields = [
"email__istartswith",
"PAN_ID__istartswith",
"full_name__istartswith",
]
empty_label = "Select all"
def label_from_instance(self, obj):
return obj.email
def filter_queryset(self, request, term, queryset=None, **dependent_fields):
return super.filter_queryset(request, term, queryset, **dependent_fields)
class MailForm(forms.Form):
to = forms.ModelMultipleChoiceField(
label="To",
queryset=User.objects.all(),
widget=UsersWidget,
)
subject = forms.CharField(max_length=78)
content = QuillFormField()
fileupload = forms.FileField()
A badge of this kind with text as "Select all" is required.
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested

