Попытка запустить сервер и получение строки с ошибкой типа
NoReverseMatch at /polls/
Reverse for 'detail' with arguments '(1,)' not found. 1 pattern(s) tried: ['polls/<int:pk>/']
my views.py
class IndexView(generic.ListView):
template_name = 'polls/index.html'
context_object_name = 'latest_question_list'
def get_queryset(self):
"""Return the last five published questions."""
return Question.objects.order_by('-pub_date')[:5]
class DetailView(generic.DetailView):
model = Question
template_name = 'polls/detail.html'
class ResultsView(generic.DetailView):
model = Question
template_name = 'polls/results.html'
Просмотры для индекса, результатов и детализации
my urls.py
from django.conf.urls import url
from . import views
app_name = 'polls'
urlpatterns = [
url('', views.IndexView.as_view(), name='index'),
url(r'^<int:pk>/', views.DetailView.as_view(),name='detail'),
url(r'^<int:pk>/results/', views.ResultsView.as_view(), name='results'),
url(r'^<int:question_id>/vote/', views.vote, name='vote'),
]
my index.html
{% 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 %}
Я пытался много раз, но у меня не было решения, пожалуйста, помогите мне.