I was trying out the url template tag and stumbled on a issue:
Caught NoReverseMatch while rendering: Reverse for ''location'' with arguments
'(<City: New York>,)' and keyword arguments '{}' not found.
In my template file I have:
{% url 'location' city_name=city.name %}
url.py
url(r'^location/(?P<city_name>.*)/$', CityView.as_view(), name="location"),
models.py
def get_absolute_url(self):
return "/location/%s" % self.name
Updated thanks to Maik Hoepfel in the comments:
Pre Django-1.5, You don’t need the
'marks in:however you can enable them by loading
urlfrom the future module. Rather than{% load url %}use{% load url from future %}.In your case, pre-Django 1.5 and without the future version of url, you can use:
I suspect it can’t find your name value because it is literally looking for
'location'.