Django URL - 渲染时捕获到了NoReverseMatch错误

3

在尝试使用url标签链接到视图时,我遇到了这个错误。错误发生在这一行:

{% 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.

url.conf (维基百科) :

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

wiki.views.algorithim :

@login_required
def index(request): 
    algorithims = Algorithms.objects.all()
    return render_to_response('wiki/algorithims/index.html', 
                          {'algorithims': algorithims 
                           },
                          context_instance=RequestContext(request)) 

模板/wiki/算法/index.html :

{% 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 %}

毕业设计,应该是“algorithm”,而不是“algorithim”。 - ThiefMaster
2个回答

2
你的视图在urlconf中被称为algorithms.view,但你在URL标签中引用它时使用了algorithm.view,即没有s

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接