Friday, August 16, 2013

Re: Can't seem to get "votes" to work right

I've made some changes to

detail.html

 
<h1>{{ poll.question }}</h1>

{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
<form action="{% url 'polls:vote' poll.id %}" method="post">
{% csrf_token %}
{% for choice in poll.choice_set.all %}
    <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
    <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br />
{% endfor %}
<input type="submit" value="Vote" />
</form>

but now an error page came up when I tried to vote for one of the polls:

Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/polls/1/vote/

Django Version: 1.5.1
Python Version: 2.7.3
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'polls')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/home/bud/.local/lib/python2.7/site-packages/django_polls-0.1-py2.7.egg/polls/views.py" in vote
  56.         return HttpResponseRedirect(reverse('polls:results', args=(p.id)))
File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py" in reverse
  496.     return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))

Exception Type: TypeError at /polls/1/vote/
Exception Value: _reverse_with_prefix() argument after * must be a sequence, not int

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate