Django: Odwróć dla 'detail' z argumentami '(' ',)' i nie znaleziono argumentów słowa kluczowego '{}'

Podążam za oficjalnym samouczkiem, aby nauczyć się Django i używać 1.5.

Miałem ten link jako część mojego szablonu indeksu, który działał poprawnie:

<li><a href="/polls/{{ poll.id }}/">{{ poll.question }}</a></li>

jest to jednak zapisane na stałe, a samouczek sugeruje, że lepszym sposobem jest użycie:

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

abyś był lepszy, gdy masz do czynienia z ogromną liczbą szablonów i musisz wprowadzić zmiany w adresie URL.

Odkąd dokonałem powyższej zmiany, po uruchomieniu aplikacji otrzymuję następujące błędy:

Exception Type: NoReverseMatch
Exception Value:    Reverse for 'detail' with arguments '('',)' and keyword arguments '{}' not found.

Moje urls.py wygląda tak:

from django.conf.urls import patterns, url

from polls import views

urlpatterns = patterns('',
    url(r'^

views.py wygląda tak:

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})

mój szablon index.html wygląda tak:

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

Zwykle mogłem łatwo odczytać, skąd pochodzi błąd i poradzić sobie z tym, ale w tym przypadku nie mogę rozpoznać przyczyny błędu, dlatego nie mogę przejść do mojego badania. Każda pomoc zostanie bardzo doceniona.

, views.index, name='index'), url(r'^(?P<poll_id>\d+)/

views.py wygląda tak:

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})

mój szablon index.html wygląda tak:

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

Zwykle mogłem łatwo odczytać, skąd pochodzi błąd i poradzić sobie z tym, ale w tym przypadku nie mogę rozpoznać przyczyny błędu, dlatego nie mogę przejść do mojego badania. Każda pomoc zostanie bardzo doceniona.

, views.detail, name='detail'), url(r'^(?P<poll_id>\d+)/results/

views.py wygląda tak:

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})

mój szablon index.html wygląda tak:

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

Zwykle mogłem łatwo odczytać, skąd pochodzi błąd i poradzić sobie z tym, ale w tym przypadku nie mogę rozpoznać przyczyny błędu, dlatego nie mogę przejść do mojego badania. Każda pomoc zostanie bardzo doceniona.

, views.results, name='results'), url(r'^(?P<poll_id>\d+)/vote/

views.py wygląda tak:

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})

mój szablon index.html wygląda tak:

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

Zwykle mogłem łatwo odczytać, skąd pochodzi błąd i poradzić sobie z tym, ale w tym przypadku nie mogę rozpoznać przyczyny błędu, dlatego nie mogę przejść do mojego badania. Każda pomoc zostanie bardzo doceniona.

, views.vote, name='vote'), )

views.py wygląda tak:

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})

mój szablon index.html wygląda tak:

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

Zwykle mogłem łatwo odczytać, skąd pochodzi błąd i poradzić sobie z tym, ale w tym przypadku nie mogę rozpoznać przyczyny błędu, dlatego nie mogę przejść do mojego badania. Każda pomoc zostanie bardzo doceniona.

questionAnswers(6)

yourAnswerToTheQuestion