I’ve encountered this error while trying to use the url tag to link to a view. The error occurs on this line:
{% for algorithim in algorithims %}
in the template.
Not really sure where I’m going wrong here.. I think I’ve attached all the necessary info but let me know if you need to see anything else.
Error :
TemplateSyntaxError at /wiki/algorithims/
Caught NoReverseMatch while rendering: Reverse for 'wiki.views.algorithim.view' with arguments '(0,)' and keyword arguments '{}' not found.
url.conf (wiki) :
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))
templates/wiki/algorithims/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 %}
Your view is called
algorithms.viewin the urlconf but you’ve referred to it in the URL tag asalgorithm.view, ie without thes.