The user selects a slot via a checkbox and also should enter a username, as shown in the template below:
<form action="/clubs/{{ club.id }}/vote/" method="post">
{% csrf_token %}
{% for slot in tom_open_slots %}
<input type="checkbox" name="slot" id="slot{{ forloop.counter }}" value="{{ slot.id }}" />
<label for="slot{{ forloop.counter }}">{{ slot.slot }} on Court {{slot.court}}</label><br />
{% endfor %}
<input type="text" name="username" />
<input type="submit" value="Reserve" />
I then would like to display the username that was typed and time selected in the checkbox. I do this through the view and template below:
def vote(request, club_id):
if 'username' in request.GET and request.GET['username'] and 'slot' in request.GET and request.GET['slot']:
username = request.GET['username']
slot = request.GET['slot']
return render_to_response('reserve/templates/vote.html',{'username':username, 'slot':slot})
else:
return HttpResponse('Please enter a username and select a time.')
{{slot}}
{{username}}
When I go to vote.html though, I always get the error message though (Please enter a username and select a time). What is incorrect in the view that is not picking up the 2 GET parameters?