Here are the examples of the python api django.forms.CheckboxSelectMultiple taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
11 Examples
3
View Complete Implementation : forms.py
Copyright MIT License
Author : ayshrv
Copyright MIT License
Author : ayshrv
def __init__(self, *args, **kwargs):
self.list_refined=[]
self.list_with_index=[]
list = kwargs.pop('list')
for i in list:
self.list_refined.append(i[0])
for index, value in enumerate(self.list_refined):
self.list_with_index.append((index,str(value)))
super(VerifyCandiForm, self).__init__(*args, **kwargs)
self.fields['Candidates'] = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,choices=self.list_with_index,required=False)
3
View Complete Implementation : forms.py
Copyright MIT License
Author : ayshrv
Copyright MIT License
Author : ayshrv
def __init__(self, *args, **kwargs):
self.list_refined=[]
self.list_with_index=[]
list = kwargs.pop('list')
for i in list:
print(i)
self.list_refined.append(i)
for index, value in enumerate(self.list_refined):
self.list_with_index.append((index,str(value)))
super(VotingForm, self).__init__(*args, **kwargs)
self.fields['Candidates'] = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,choices=self.list_with_index,required=False)
3
View Complete Implementation : forms.py
Copyright GNU General Public License v3.0
Author : CodigoSur
Copyright GNU General Public License v3.0
Author : CodigoSur
def __init__(self, question, *args, **kwargs):
super(QuestionForm, self).__init__(*args, **kwargs)
self.question = question
choices = [(a.id, a.text) for a in Answer.objects.filter(question=question)]
field_args = {
"choices": choices,
"label": question.text.capitalize()
}
if question.allow_multiple_answers:
self.fields['answers'] = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple(), **field_args)
else:
self.fields['answers'] = forms.ChoiceField(widget=forms.RadioSelect(), **field_args)
3
View Complete Implementation : views.py
Copyright BSD 2-Clause "Simplified" License
Author : evrenesat
Copyright BSD 2-Clause "Simplified" License
Author : evrenesat
def __init__(self, *args, **kwargs):
req_phone = kwargs.pop('req_phone',False)
super(addPlaceForm, self).__init__(*args, **kwargs)
self.fields['tags'].widget = forms.CheckboxSelectMultiple()
self.fields["tags"].queryset = Tag.objects.all()
if not req_phone:
del self.fields['phone']
3
View Complete Implementation : test_checkboxselectmultiple.py
Copyright GNU Affero General Public License v3.0
Author : nesdis
Copyright GNU Affero General Public License v3.0
Author : nesdis
def test_separate_ids_constructor(self):
"""
Each input gets a separate ID when the ID is pasted to the constructor.
"""
widget = CheckboxSelectMultiple(attrs={'id': 'abc'}, choices=[('a', 'A'), ('b', 'B'), ('c', 'C')])
html = """
<ul id="abc">
<li>
<label for="abc_0"><input checked type="checkbox" name="letters" value="a" id="abc_0"> A</label>
</li>
<li><label for="abc_1"><input type="checkbox" name="letters" value="b" id="abc_1"> B</label></li>
<li>
<label for="abc_2"><input checked type="checkbox" name="letters" value="c" id="abc_2"> C</label>
</li>
</ul>
"""
self.check_html(widget, 'letters', ['a', 'c'], html=html)
0
View Complete Implementation : forms.py
Copyright MIT License
Author : ayshrv
Copyright MIT License
Author : ayshrv
def __init__(self, *args, **kwargs):
self.first_list_refined=[]
self.first_list_with_index=[]
self.second_list_refined=[]
self.second_list_with_index=[]
self.third_list_refined=[]
self.third_list_with_index=[]
self.fourth_list_refined=[]
self.fourth_list_with_index=[]
self.phd_list_refined=[]
self.phd_list_with_index=[]
self.first = kwargs.pop('first')
self.first_left = kwargs.pop('first_left')
self.second = kwargs.pop('second')
self.second_left = kwargs.pop('second_left')
self.third = kwargs.pop('third')
self.third_left = kwargs.pop('third_left')
self.fourth = kwargs.pop('fourth')
self.fourth_left = kwargs.pop('fourth_left')
self.phd = kwargs.pop('phd')
self.phd_left = kwargs.pop('phd_left')
for i in self.first:
self.first_list_refined.append(i)
for index, value in enumerate(self.first_list_refined):
self.first_list_with_index.append((index,str(value)))
for i in self.second:
self.second_list_refined.append(i)
for index, value in enumerate(self.second_list_refined):
self.second_list_with_index.append((index,str(value)))
for i in self.third:
self.third_list_refined.append(i)
for index, value in enumerate(self.third_list_refined):
self.third_list_with_index.append((index,str(value)))
for i in self.fourth:
self.fourth_list_refined.append(i)
for index, value in enumerate(self.fourth_list_refined):
self.fourth_list_with_index.append((index,str(value)))
for i in self.phd:
self.phd_list_refined.append(i)
for index, value in enumerate(self.phd_list_refined):
self.phd_list_with_index.append((index,str(value)))
super(VerifyResultForm, self).__init__(*args, **kwargs)
self.fields['First Year'] = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,choices=self.first_list_with_index,required=False)
self.fields['Second Year'] = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,choices=self.second_list_with_index,required=False)
self.fields['Third Year'] = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,choices=self.third_list_with_index,required=False)
self.fields['Fourth Year'] = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,choices=self.fourth_list_with_index,required=False)
self.fields['Ph.D'] = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple,choices=self.phd_list_with_index,required=False)
0
View Complete Implementation : helper.py
Copyright GNU Affero General Public License v3.0
Author : helfertool
Copyright GNU Affero General Public License v3.0
Author : helfertool
def __init__(self, *args, **kwargs):
self.helper = kwargs.pop('helper')
self.user = kwargs.pop('user')
super(HelperAddShiftForm, self).__init__(*args, **kwargs)
event = self.helper.event
# field that contains all shifts if
# - user is admin for shift/job
# - helper is not already in this shift
# all administered shifts
administered_jobs = [job for job in event.job_set.all()
if job.is_admin(self.user)]
shifts = Shift.objects.filter(job__event=event,
job__in=administered_jobs)
# exclude already taken shifts
shifts = shifts.exclude(id__in=self.helper.shifts.all())
# add field
self.fields['shifts'] = forms.ModelMultipleChoiceField(
widget=forms.CheckboxSelectMultiple,
queryset=shifts, required=True)
0
View Complete Implementation : helper.py
Copyright GNU Affero General Public License v3.0
Author : helfertool
Copyright GNU Affero General Public License v3.0
Author : helfertool
def __init__(self, *args, **kwargs):
self.helper = kwargs.pop('helper')
self.user = kwargs.pop('user')
super(HelperAddCoordinatorForm, self).__init__(*args, **kwargs)
event = self.helper.event
# field that contains all jobs if
# - user is admin for job
# - helper is not already coordinator for this job
# all administered jobs
coordinated_jobs = self.helper.coordinated_jobs
jobs = [job.pk for job in event.job_set.all()
if job.is_admin(self.user) and job not in coordinated_jobs]
# we need a queryset
jobs = Job.objects.filter(pk__in=jobs)
# add field
self.fields['jobs'] = forms.ModelMultipleChoiceField(
widget=forms.CheckboxSelectMultiple,
queryset=jobs, required=True)
0
View Complete Implementation : crispy_forms_bulma_field.py
Copyright MIT License
Author : jhotujec
Copyright MIT License
Author : jhotujec
@register.filter
def is_checkboxselectmultiple(field):
return isinstance(field.field.widget, forms.CheckboxSelectMultiple)
0
View Complete Implementation : admin.py
Copyright MIT License
Author : mangadventure
Copyright MIT License
Author : mangadventure
def __init__(self, *args, **kwargs):
super(SeriesAdminForm, self).__init__(*args, **kwargs)
self.fields['categories'].widget.widget = CheckboxSelectMultiple()
0
View Complete Implementation : test_models.py
Copyright GNU Affero General Public License v3.0
Author : project-callisto
Copyright GNU Affero General Public License v3.0
Author : project-callisto
def test_generates_checkbox(self):
field = mocks.MockQuestion(self.question.serialized).make_field()
self.astertEqual(len(field.choices), 5)
self.astertEqual(field.choices[4][1], "This is choice 4")
self.astertIsInstance(field.widget, forms.CheckboxSelectMultiple)