class StatusForm(ModelForm):
bases = forms.ModelMultipleChoiceField(
queryset=Base.objects.all(), #this should get overwritten
widget=forms.SelectMultiple,
)
class Meta:
model = HiringStatus
exclude = ('company', 'date')
def __init__(self, *args, **kwargs):
super(StatusForm, self).__init__(*args, **kwargs)
if kwargs.has_key('bases_queryset'):
self.fields['bases'].queryset = kwargs['bases_queryset']
I want to add an option to this form that allows me to create a form like so:
form = StatusForm(bases_queryset=Base.objects.filter([...])
But I somehow need to "add" that keyword argument to the class so it will be recognized. They way it is now, I just get this error:
__init__() got an unexpected keyword argument 'bases_queryset'