On Tuesday, 5 August 2014 13:28:28 UTC+1, VIPUL BANSAL wrote:
>
> Hi,
>
> I trying to create a drop-down which gets repopulated every time we land 
> on the page.
>
> If I use the following code everything works correctly:
>
> class DeleteMappingForm(forms.Form) :
>     subAreaDropDown = forms.ChoiceField(choices = fetchChoices())
>
> def deleteMapping(request):
>         form = DeleteMappingForm()
>         return render(request,'polls/deleteMapping.html', {'form' : form })
>
>
> But when I try to make things dynamic, things do not run
>
> class DeleteMappingForm(forms.Form) :
>     def _init_(self, *args, **kwargs):
>         super(DeleteMappingForm, self)._init_(*args, **kwargs)
>         self.fields['subAreaDropDown'] = forms.ChoiceField(choices = 
> fetchChoices())
>
> def deleteMapping(request):
>         form = DeleteMappingForm()
>         return render(request,'polls/deleteMapping.html', {'form' : form })
>
> P.S. : fetchChoices() is a function which returns me the choices.
>
> Can some one help me identify the problem?
>
> Thanks in advance.
>


The initialization method is called __init__ (two underscores each side), 
not _init_.
--
DR. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b20cf67d-e556-4203-b84a-10fe093e6531%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to