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

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -