Django tutorial part 3 - NoReverseMatch at /polls/
Question: I have been following the [Django tutorial part
3](https://docs.djangoproject.com/en/1.10/intro/tutorial03/) and am getting
the following error when I attempt to view <http://localhost:8000/polls/>:

    
    
    **Reverse for 'detail' with arguments '('',)' and keyword arguments '{}' not found. 1 pattern(s) tried: [u'polls/(?P<question_id>[0-9]+)/$']**
    

My files are as follows:

mysite/urls.py:

    
    
    from django.conf.urls import include, url
    from django.contrib import admin
    urlpatterns = [
        url(r'^polls/', include('polls.urls', namespace="polls")),
        url(r'^admin/', admin.site.urls),
    ]
    

polls/urls.py:

    
    
    from django.conf.urls import url
    from . import views
    app_name = 'polls'
    urlpatterns = [
        url(r'^$', views.index, name='index'),
        url(r'^(?P<question_id>[0-9]+)/$', views.detail, name='detail'),
        url(r'^(?P<question_id>[0-9]+)/results/$', views.results, name='results'),
        url(r'^(?P<question_id>[0-9]+)/vote/$', views.vote, name='vote'),
    ]
    

polls/detail.html:

    
    
    <h1>{{ question.question_text }}</h1>
    <ul>
    {% for choice in question.choice_set.all %}
        <li>{{ choice.choice_text }}</li>
    {% endfor %}
    </ul>
    

polls/templates/polls/index.html:

    
    
    <li><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li>
    

**What does this error mean?**

**How do I debug it?**

**Can you suggest a fix?**

N.b. I have seen and tried the answers to the similar questions:

[NoReverseMatch at /polls/ (django
tutorial)](http://stackoverflow.com/questions/33151816/noreversematch-at-
polls-django-tutorial?rq=1) [Django 1.8.2 -- Tutorial Chapter 3 -- Error:
NoReverseMatch at /polls/ -- Python
3.4.3](http://stackoverflow.com/questions/31103954/django-1-8-2-tutorial-
chapter-3-error-noreversematch-at-polls-python) [NoReverseMatch - Django 1.7
Beginners
tutorial](http://stackoverflow.com/questions/27645132/noreversematch-
django-1-7-beginners-tutorial?rq=1) [Django: Reverse for 'detail' with
arguments '('',)' and keyword arguments '{}' not
found](http://stackoverflow.com/questions/19336076/django-reverse-for-detail-
with-arguments-and-keyword-arguments-n#19336837)
<https://groups.google.com/forum/#!msg/django-users/etSR78dgKBo/euSYcSyMCgAJ>
[NoReverseMatch at /polls/ (django
tutorial)](http://stackoverflow.com/questions/33151816/noreversematch-at-
polls-django-tutorial?rq=1)
<https://www.reddit.com/r/django/comments/3d43gb/noreversematch_at_polls1results_in_django/>

Edit, I initially missed the following question. Its excellent answer
partially answers my question (how to debug) but does not cover my specific
problem.

[What is a NoReverseMatch error, and how do I fix
it?](http://stackoverflow.com/questions/38390177/what-is-a-noreversematch-
error-and-how-do-i-fix-it)


Answer: This was the problem:

polls/templates/polls/index.html should have been:

    
    
    {% if latest_question_list %}
        <ul>
        {% for question in latest_question_list %}
            <li><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li>
        {% endfor %}
        </ul>
    {% else %}
        <p>No polls are available.</p>
    {% endif %}
    

I had inadvertantly replaced the entire file with the following line, rather
than just updating the relevant line (implied
[here](https://docs.djangoproject.com/en/1.10/intro/tutorial03/#namespacing-
url-names)):

    
    
    <li><a href="{% url 'polls:detail' question.id %}">{{ question.question_text }}</a></li>
    

As stated by @Sayse in the comments, this would mean that question.id is empty
resulting in the error.

