I have a class like this.
class AddNoteForm(forms.Form):
def __init__(self, test_values, *args):
self.custom_choices = test_values
super(AddNoteForm, self).__init__()
self.fields['choices'] = forms.ModelMultipleChoiceField(label='Test Choices', choices=self.custom_choices)
I'd like to pass this tuple during class creation.
test_values = (
('name1', 'value1'),
('name2', 'value2'),
('name3', 'value3'),
)
form = AddNoteForm(test_values)
But whenever I do so, I get a __init__() takes at least 2 arguments (2 given)
error. I'm also using python 2.7 (and Django 1.8).
I look at the variables in the debug page and self.custom_choices contain the right values (test_values that I passed into the function).
Any ideas?
forms.Form, from whichAddNoteForminherits?