Форум сайта python.su
Есть такая формочка
class ExchangeForm(forms.Form): MY_CHOICE = [('1', 'Value 1'), ('2', 'Value 2'), ('3', 'Value 3')] count = forms.IntegerField() my_choice_field = forms.ChoiceField(choices=MY_CHOICE)
<form action="{% url 'my_view' %}" method="POST">{% csrf_token %} Amount: {{ form.count }}<br> From: <select title="from"> {% for x,y in form.my_choice_field.field.choices %} <option value="{{ x }}">{{ y }}</option> {% endfor %} </select><br> <input type="submit"/> </form>
if request.method == 'POST': form = Form(request.POST) if form.is_valid(): amount = form.cleaned_data['count'] my_field = form.cleaned_data['my_choice_field'] else: form = Form() return render_to_response('template.html', {'form': form}, context_instance=RequestContext(request))
Офлайн
<select title="from">
Офлайн
благодарю, починил
Офлайн