views:

597

answers:

3

guys: I was trying to use the url template tag in django, but no lucky,

I defined my urls.py like this

urlpatterns = patterns('',            

                       url(r'^analyse/$',              views.home,  name="home"),
                       url(r'^analyse/index.html',     views.index, name="index"),
                       url(r'^analyse/setup.html',     views.setup, name="setup"),
                       url(r'^analyse/show.html',      views.show,  name="show"),
                       url(r'^analyse/generate.html',  views.generate, name="generate"),

I defined the url pattern in my view like this

{% url 'show'%}

then I got this error message

Caught an exception while rendering: Reverse for ''show'' with arguments '()' and keyword arguments '{}' not found.

Original Traceback (most recent call last): File "/Library/Python/2.5/site-packages/django/template/debug.py", line 71, in render_node result = node.render(context) File "/Library/Python/2.5/site-packages/django/template/defaulttags.py", line 155, in render nodelist.append(node.render(context)) File "/Library/Python/2.5/site-packages/django/template/defaulttags.py", line 382, in render raise e NoReverseMatch: Reverse for ''show'' with arguments '()' and keyword arguments '{}' not found.

I am wondering why django failed to render? what is the right way to define it in the tempalte?

A: 

For what is is worth, I had the same issue and while I do not remember the reason why now, this resolved it for me. Example from a SCRUM app I was working on.

url(r'^$', 'scrum.views.index',  name='scrum-index'),
SleighBoy
+1  A: 

The problem is your single quotes around 'show'. Change this to "show" and it should work out for you.

See here

rh0dium
A: 

You may need to be a little more specific on which view you're trying to use:

{% url appname.views.show %}
Lance McNearney

related questions