Cameron Sima
Cameron Sima

Reputation: 5385

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

I've looked at a few similarly-titled questions on here, but none seem to help. Error:

NoReverseMatch at /articles/
Reverse for 'index' with arguments '('',)' and 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 at line 7**
Reverse for 'index' with arguments '('',)' and 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       {% for 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 are available.</p>
    12  {% endif %}

articles/urls.py:

from django.conf.urls import patterns, url
from 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>
    {% for article in latest_articles_list %}
        <li><a href="{% url 'articles:index' content.slugline %}">{{ content.title }}</a></li>
    {% endfor %}
    </ul>
{% else %}
    <p>No articles are available.</p>
{% endif %}

main urls.py:

from django.conf.urls import patterns, include, url

from 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 this code is taken from the django tutorial. I've been comparing mine against the stock code, and can't seem to find the problem.

Upvotes: 0

Views: 3749

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599590

You're trying to pass an argument to the index view, for some reason; but that view doesn't accept one. It should just be:

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

Upvotes: 3

Related Questions