こんにちは、私は学生データベースアプリに取り組んでおり、より多くの機能を作成してこのエラーに遭遇しました.すべてが明確に見えますが、以前にこのアプリで遭遇したため、このエラーの意味を理解しました. 何がうまくいかなかったのかわかりません。
TemplateSyntaxError at /school/
Caught NoReverseMatch while rendering: Reverse for 'cat' with arguments '('',)' and keyword arguments '{}' not found.
Exception Type: TemplateSyntaxError
Exception Value: Caught NoReverseMatch while rendering: Reverse for 'cat' with arguments '('',)' and keyword arguments '{}' not found.
In template /home/tafe/mysite/school/templates/index.html, error at line 3
Caught NoReverseMatch while rendering: Reverse for 'cat' with arguments '('',)' and keyword arguments '{}' not found.
1 {% if students %}
2 <ul>
3 {% for student in students %}
4 <li><a href="{% url school:cat poll.id %}">{{student.First_name}}</li>
私のviews.py
from mysite.school.models import student
from django.shortcuts import render_to_response
from django.http import HttpResponse,Http404
def index(request):
students = student.objects.all()
return render_to_response('index.html',{'students':students})
def cat(request,poll_id):
students = get_object_or_404(student,pk =poll_id)
return render_to_response('student.html',{'students':student})
私の index.html
{% if students %}
<ul>
{% for student in students %}
<li><a href="{% url myapp:cat poll.id %}">{{student.First_name}}</li>
{% endfor %}
</ul>
{% endif %}
私の学生.html
{% if students %}
<ul>
{% for student in students %}
<li>{{student.First_name}}</li>
{% endfor %}
</ul>
私の URLconf
from django.conf.urls.defaults import patterns,include , url
from django.contrib import admin
from mysite.school.views import index,cat
admin.autodiscover()
urlpatterns = patterns ('',
url(r'^$',index),
url(r'^(?P<poll_id>\d+)/$',cat,name='cat'),
)