Why does django call __init__() twice for form fields -
i'm trying use django-simple-autocomplete in form. however, when add debug prints simple_autocomplete.widgets, see each form field's widget's __init__() called twice, first parameters supplied in form specification , second time without any arguments, breaks excpects parameter.
i have work around doing following:
class myform(forms.form): def __init__(self,*args, **kwargs): super(myform, self).__init__(*args, **kwargs) self.fields['foo'] = autocompletewidget(url="/json_url") foo = forms.modelchoicefield( widget=none, .... ) why on earth so?
edit / clarification:
- this happens if don't have above workaround, instead have widget=mywidget() in foo definition.
- it's widget's
__init__()called twice. - @zubair89 - have
def __init__()- that's how found out called twice!
Comments
Post a Comment