I’m basically trying to use this form as a check: If option 1(value 0) is selected: render page1, if option 2(value 1) is selected: render page 2.
Within my template I have
<form method="POST" action="/account/subscription/">
{% csrf_token %}
<select size="1">
<option value="0" name="plan">Plan 1</option>
<option value="1" name="plan">Plan 2</option>
</select>
</form>
view:
def subscription(request):
if request.method != 'POST':
return HttpResponseRedirect('/signup/additional/')
else:
if '0' in request.POST:
return render_to_response('signup/payment_plan1.html', context_instance=RequestContext(request))
else:
return render_to_response('signup/payment_plan2.html', context_instance=RequestContext(request))
Once posted… Looking within my network path, all the post returns is the csrf. I’m obviously doing something wrong. Can I use select options as a check within my view?
You need a
nameattribute for yourselectelement if you want to POST something.