Tuesday, 20 August 2013

Django: Reverse not found > {% url %} in template

Django: Reverse not found > {% url %} in template

This problem seems simple and it is described multiple times in SO, but I
still can't figure out why it isn't working in my case.
So, I have a url declared in urls.py
urlpatterns = patterns('',
url(r'^(?P<country>[-\w]+)/$', CountryListView.as_view(),
name='list_by_country'),)
and in my template I'm calling the url
<a href="{% url 'list_by_country' country.country__name %}" >{{
country.country__name }}</a>
However, I am getting the error message that the url could not be reversed
Reverse for 'list_by_country' with arguments '(u'United Kingdom',)' and
keyword arguments '{}' not found
What is causing the reverse error? Are spaces in the argument maybe not
allowed?

No comments:

Post a Comment