i am learning django from official django tutorial. and i am getting this error when vote something from form. this caused from - probably - vote function under views.py
here is my views.py / vote function :
def vote(request,poll_id):p=get_object_or_404(Poll, pk=poll_id)try:selected_choice = p.choice_set.get(pk=request.POST['choice'])except (KeyError, Choice.DoesNotExist):return render_to_response('polls/detail.html', {'poll':p,'error_message' : "didint select anything ",}, context_instance= RequestContext(request))else:selected_choice.votes += 1selected_choice.save()return HttpResponseRedirect(reverse('polls.views.results', args=(p.id,)))
and this is error message screen :
**ValueError at /polls/2/vote/
invalid literal for int() with base 10: 'on'**
Request Method: POST Request URL: 127.0.0.1:8000/polls/2/vote/
Django Version: 1.4 Exception Type: ValueError Exception Value: invalid literal for int() with base 10: 'on' ExceptionLocation: /usr/local/lib/python2.7/dist-packages/django/db/models/fields/init.pyin get_prep_value, line 537
and here is my polls/urls.py :
from django.conf.urls import patterns, include, url
urlpatterns = patterns('polls.views',
url(r'^$', 'index'),url(r'^(?P<poll_id>\d+)/$','detail'),url(r'^(?P<poll_id>\d+)/results/$','results'),url(r'^(?P<poll_id>\d+)/vote/$','vote'),
)
and here is project/urls.py :
from django.conf.urls import patterns, include, url
urlpatterns = patterns('polls.views',
url(r'^$', 'index'),url(r'^(?P<poll_id>\d+)/$','detail'),url(r'^(?P<poll_id>\d+)/results/$','results'),url(r'^(?P<poll_id>\d+)/vote/$','vote'),
)