Friday, August 24, 2012

Re: NoReverseMatch Error

Hi, Can you please elaborate on how to use this block in the template code?  I've tried adding this into my details template code in various places and cannot get it to successfully work.  Also, any suggestions/examples you could point me to would be much appreciated.

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

{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}


{% import url from future %}
<form action="/polls/{{ poll.id }}/vote/" 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>

Thanks,
Syam

On Wednesday, August 15, 2012 4:53:23 AM UTC-7, Karen Tracey wrote:
On Tue, Aug 14, 2012 at 10:46 AM, Serge G. Spaolonzi <se...@cobalys.com> wrote:
Try removing the quotes from 'polls.views.vote':
<form action="{% url polls.views.vote poll.id %}" method="post">


Note that will work for 1.4 but it's doing things the old way, and that will break in 1.5. Much better to add {% import url from future %} and have code that will continue to work with the next release of Django. Removing the quotes is not the best approach at this time.
 
Karen
--
http://tracey.org/kmt/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/La3h_D5OnOQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment