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.