Wednesday 15 August 2012

python - Django NoReverseMatch error Reverse for 'detail' with arguments '('',)' and keyword arguments '{}' not found -



python - Django NoReverseMatch error Reverse for 'detail' with arguments '('',)' and keyword arguments '{}' not found -

i've looked @ few similarly-titled questions on here, none seem help. error:

noreversematch @ /articles/ reverse 'index' arguments '('',)' , keyword arguments '{}' not found. 1 pattern(s) tried: [u'articles/$'] error during template rendering in template c:\projects\django\the_bluntist\articles\templates\articles\index.html, **error @ line 7** reverse 'index' arguments '('',)' , keyword arguments '{}' not found. 1 pattern(s) tried: [u'articles/$'] 1 {% load staticfiles %} 2 3 <link rel="stylesheet" type="text/css" href="{% static 'articles/style.css' %}" /> 4 {% if latest_articles_list %} 5 <ul> 6 {% article in latest_articles_list %} 7 <li><a href="{% url 'articles:index' content.slugline %}">{{ content.title }}</a></li> 8 {% endfor %} 9 </ul> 10 {% else %} 11 <p>no articles available.</p> 12 {% endif %}

articles/urls.py:

from django.conf.urls import patterns, url articles import views urlpatterns = patterns('', url(r'^$', views.indexview.as_view(), name = 'index'), url(r'^(?p<slugline>[-\w\d]+),(?p<pk>\d+)/$', views.detailview.as_view(), name='detail') )

index.html:

{% load staticfiles %} <link rel="stylesheet" type="text/css" href="{% static 'articles/style.css' %}" /> {% if latest_articles_list %} <ul> {% article in latest_articles_list %} <li><a href="{% url 'articles:index' content.slugline %}">{{ content.title }}</a></li> {% endfor %} </ul> {% else %} <p>no articles available.</p> {% endif %}

main urls.py:

from django.conf.urls import patterns, include, url django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^articles/', include('articles.urls', namespace="articles")), url(r'^admin/', include(admin.site.urls)), )

a lot of code taken django tutorial. i've been comparing mine against stock code, , can't seem find problem.

you're trying pass argument index view, reason; view doesn't take one. should be:

<a href="{% url 'articles:index' %}">

python django

No comments:

Post a Comment