I am trying to create dependent dropdowns following this link: http://www.devinterface.com/blog/en/2011/02/how-to-implement-two-dropdowns-dependent-on-each-other-using-django-and-jquery/
But I have this form:
class FrequencyForm(CityForm)
def __init__(self, *args, **kwargs):
super(FrequencyForm, self).__init__(*args, **kwargs)
self.frequency_list = [('-1','None')]
self.fields['term'] = forms.ChoiceField(choices=self.frequency_list, required=True, widget=forms.RadioSelect())
I don't want the default value to appear when the list populates. What should I do?
In
self.frequency_list
is a list oftuple
s. As far as I can see there is only one choice for your dropdown i.e[('-1','None')]
. Try putting an entry at first index in this list, for eg.and now the first one will become the default selected element.
For more you can refer this : Setting the selected value on a Django forms.ChoiceField