Whenever im running form.is_valid() i get the error:
Select a valid choice. That choice is not one of the availablechoices.
Here is what I do in my view:
timeframes = HostTimeFrame.objects.all()
if request.method == 'POST':form = SelectDatesForm(request.POST, timeframes=timeframes)if form.is_valid():pass
else:form = SelectDatesForm(timeframes=timeframes)
My form does this:
class SelectDatesForm(forms.Form):timeframes = forms.ModelChoiceField(queryset=HostTimeFrame.objects.none(), widget=forms.CheckboxSelectMultiple,empty_label=None)def __init__(self, *args, **kwargs):qs = kwargs.pop('timeframes')super(SelectDatesForm, self).__init__(*args, **kwargs)self.fields['timeframes'].queryset = qs.order_by('start')
Ive been trying for hours to find where this actual validation is done, and i found it, created a bug here.