I have a GET form with checkboxes. When i select several boxes and submit the form it produces a link with several variables with the same name. How do i get each value of those variables in the view?
class SearchJobForm(ModelForm):
query = forms.CharField()
types = forms.ModelChoiceField(queryset=JobType.objects.all(), widget=forms.CheckboxSelectMultiple())
class Meta:
model = Job
request.GETis aQueryDictinstance that has agetlistmethod. If you callyou’ll get back a list with all the values, e.g. if the querystring is
mykey=1&mykey=2, you’ll get['1', '2']fromgetlist.If you use the
MultipleChoiceField, Django handles this automatically for you.