Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Receiving error: Reverse for with arguments '()' and keyword arguments not found

I am getting an error creating a link in my Django template.

My template looks like this:

<a href="{% url 'location_detail' pk=location.id %}">{{ location.name }}</a>

My urls.py looks like:

url(r'^location(?P<pk>\d+)/$', views.location_detail, name="location_detail"),

My view looks like:

def location_detail(request, pk=None):

I get the error:

Reverse for views.location_detail with arguments '()' and keyword arguments '{u'pk': 1L}' not found.

I'm using Django 1.5 and python 2.7.2

Thanks!

like image 633
Atma Avatar asked Dec 12 '22 12:12

Atma


1 Answers

The problem was that I had a name space on the primary project urls.py:

url(r'^com/', include('com.urls', namespace="com")),

Changing the url to:

{% url 'com:location_detail' pk=location.id %}

That did the trick

like image 185
Atma Avatar answered Dec 22 '22 15:12

Atma