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!
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With