Django URL-在渲染时捕获到NoReverseMatch
我在尝试使用url标记链接到视图时遇到此错误。错误发生在这一行:Django URL-在渲染时捕获到NoReverseMatch,django,django-templates,Django,Django Templates,我在尝试使用url标记链接到视图时遇到此错误。错误发生在这一行: {% for algorithim in algorithims %} 在模板中 我不太确定我在这出了什么错。。我想我已经附上了所有必要的信息,但是如果你需要看其他的东西,请告诉我 错误: TemplateSyntaxError at /wiki/algorithims/ Caught NoReverseMatch while rendering: Reverse for 'wiki.views.algorithim.view'
{% for algorithim in algorithims %}
在模板中
我不太确定我在这出了什么错。。我想我已经附上了所有必要的信息,但是如果你需要看其他的东西,请告诉我
错误:
TemplateSyntaxError at /wiki/algorithims/
Caught NoReverseMatch while rendering: Reverse for 'wiki.views.algorithim.view' with arguments '(0,)' and keyword arguments '{}' not found.
from django.conf.urls.defaults import *
urlpatterns = patterns('wiki.views',
url(r'^$', 'index'),
url(r'^algorithims/$', 'algorithims.index'),
url(r'^algorithims/(?P<alg_id>\d+)/$', 'algorithims.view')
)
@login_required
def index(request):
algorithims = Algorithms.objects.all()
return render_to_response('wiki/algorithims/index.html',
{'algorithims': algorithims
},
context_instance=RequestContext(request))
{% extends "wiki/base.html" %}
{% block content %}
<div>
{% if algorithims %}
{% for algorithim in algorithims %}
<a href="{% url wiki.views.algorithim.view algorithim.alg_id %}">{{ algorithim.alg_name }}</a>
{% endfor %}
{% else %}
No algorithims found!
{% endif %}
</div>
{% endblock %}
url.conf(wiki):
TemplateSyntaxError at /wiki/algorithims/
Caught NoReverseMatch while rendering: Reverse for 'wiki.views.algorithim.view' with arguments '(0,)' and keyword arguments '{}' not found.
from django.conf.urls.defaults import *
urlpatterns = patterns('wiki.views',
url(r'^$', 'index'),
url(r'^algorithims/$', 'algorithims.index'),
url(r'^algorithims/(?P<alg_id>\d+)/$', 'algorithims.view')
)
@login_required
def index(request):
algorithims = Algorithms.objects.all()
return render_to_response('wiki/algorithims/index.html',
{'algorithims': algorithims
},
context_instance=RequestContext(request))
{% extends "wiki/base.html" %}
{% block content %}
<div>
{% if algorithims %}
{% for algorithim in algorithims %}
<a href="{% url wiki.views.algorithim.view algorithim.alg_id %}">{{ algorithim.alg_name }}</a>
{% endfor %}
{% else %}
No algorithims found!
{% endif %}
</div>
{% endblock %}
模板/wiki/algorithims/index.html:
TemplateSyntaxError at /wiki/algorithims/
Caught NoReverseMatch while rendering: Reverse for 'wiki.views.algorithim.view' with arguments '(0,)' and keyword arguments '{}' not found.
from django.conf.urls.defaults import *
urlpatterns = patterns('wiki.views',
url(r'^$', 'index'),
url(r'^algorithims/$', 'algorithims.index'),
url(r'^algorithims/(?P<alg_id>\d+)/$', 'algorithims.view')
)
@login_required
def index(request):
algorithims = Algorithms.objects.all()
return render_to_response('wiki/algorithims/index.html',
{'algorithims': algorithims
},
context_instance=RequestContext(request))
{% extends "wiki/base.html" %}
{% block content %}
<div>
{% if algorithims %}
{% for algorithim in algorithims %}
<a href="{% url wiki.views.algorithim.view algorithim.alg_id %}">{{ algorithim.alg_name }}</a>
{% endfor %}
{% else %}
No algorithims found!
{% endif %}
</div>
{% endblock %}
{%extends“wiki/base.html”%}
{%block content%}
{%if algorithims%}
{algorithims%中algorithim的%
{%endfor%}
{%else%}
没有找到算法!
{%endif%}
{%endblock%}
您的视图被称为算法。在urlconf中查看,但您在URL标记中将其称为算法。查看,即没有s
尝试查看这篇问了非常类似问题的帖子
fyp,这是“算法”,而不是“算法”