Robse
Robse

Reputation: 915

Another django NoReverseMatch

In project.urls:

url(r'^category/', include('category.urls')),

In project/category/category.urls (patterns prefixed with 'project.category.views'):

url(r'^list/', 'category_list', name='category_list_name'),

In project/templates/base.html:

{% url 'category_list_name' %}

Gives me:

Caught NoReverseMatch while rendering: Reverse for ''category_list_name'' with arguments '()' and keyword arguments '{}' not found.

In the shell, I get the same error for this:

>>> reverse(category.views.category_list)

But this works fine:

>>> reverse("category_list_name")
u'/en/category/list/'

In a view, I get an empty string for reversing the named url. Like you see I'm also using localeurl, but I think that shouldn't matter?

Any ideas?

Upvotes: 0

Views: 136

Answers (1)

Mark Lavin
Mark Lavin

Reputation: 25154

{% url 'category_list_name' %} looks like you are using Django 1.3 but do you have {% load url from future %} in your template? If not you should use {% url category_list_name %} instead. Quotes make all the difference.

Upvotes: 2

Related Questions