python - Django 1.6 name select is not defined -
python - Django 1.6 name select is not defined -
i'm trying show dropdown menu in template, next error
file "forms.py" in dropdownselectionform 101. selection = forms.choicefield(choices=my_choices, widget = select) exception type: nameerror @ / exception value: name 'select' not defined
here template i'm trying show form
<form action="/doclistings/" method="post" >{% csrf_token %} <select class="form-control" id="s1" name="selection"> <option><b>find doctor...</b></option> {% value, text in form.selection.field.choices %} <option value="{{ value }}">{{ text }}</option> {% endfor %} </select>
here forms.py
my_choices = ( ('dermatologist', 'dermatologist'), ('dentist', 'dentist'), ('opthalmologist', 'opthalmologist'), ) class dropdownselectionform(forms.form): selection = forms.choicefield(choices=my_choices, widget = select)
like else in python, need reference object properly. in case select made available via forms module, choicefield.
selection = forms.choicefield(choices=my_choices, widget=forms.select)
python django forms choicefield
Comments
Post a Comment