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.

-- 
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/fdfe2ad5-1d59-468d-a7de-5563ccb2d4b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to