Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango: Reverse for 'detail' with arguments '('',)' and keyword arguments '{}' not found
    primarykey
    data
    text
    <p>I'm following the official tutorial to learn Django and using 1.5.</p> <p>I had this link as part of my index template, which was working fine:</p> <pre><code>&lt;li&gt;&lt;a href="/polls/{{ poll.id }}/"&gt;{{ poll.question }}&lt;/a&gt;&lt;/li&gt; </code></pre> <p>however, this is hardcoded and the tutorial suggested a better way was to use:</p> <pre><code>&lt;li&gt;&lt;a href="{% url 'detail' poll.id %}"&gt;{{ poll.question }}&lt;/a&gt;&lt;/li&gt; </code></pre> <p>so that you'll be better of when dealing with huge number of templates and u have to make changes to the url.</p> <p>Since I made the above change I get the following errors when I run the app:</p> <pre><code>Exception Type: NoReverseMatch Exception Value: Reverse for 'detail' with arguments '('',)' and keyword arguments '{}' not found. </code></pre> <p>My urls.py looks like this:</p> <pre><code>from django.conf.urls import patterns, url from polls import views urlpatterns = patterns('', url(r'^$', views.index, name='index'), url(r'^(?P&lt;poll_id&gt;\d+)/$', views.detail, name='detail'), url(r'^(?P&lt;poll_id&gt;\d+)/results/$', views.results, name='results'), url(r'^(?P&lt;poll_id&gt;\d+)/vote/$', views.vote, name='vote'), ) </code></pre> <p>views.py looks like this:</p> <pre><code>from django.shortcuts import render, get_object_or_404 from django.http import Http404 from polls.models import Poll def index(request): latest_poll_list = Poll.objects.order_by('-pub_date')[:5] context = {'latest_poll_list': latest_poll_list} return render(request, 'polls/index.html', context) def detail(request, poll_id): poll = get_object_or_404(Poll, pk = poll_id) return render(request, 'polls/detail.html', {'poll': poll}) </code></pre> <p>my index.html template looks like this:</p> <pre><code>{% if latest_poll_list %} &lt;ul&gt; {% for poll in latest_poll_list %} &lt;li&gt;&lt;a href="{% url 'polls:detail' poll_id %}"&gt;{{ poll.question }}&lt;/a&gt;&lt;/li&gt; {% endfor %} &lt;/ul&gt; {% else %} &lt;p&gt; No polls are available.&lt;/p&gt; {% endif %} </code></pre> <p>Usually I could easily read where the error is coming from and deal with it but in this case I can't spot the cause of the error hence I'm unable to progress with my study. Any help will be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload