0

I always get this error when try to use url tag:

    Reverse for 'show' with arguments '()' and keyword arguments 
    '{}' not   found. 1 pattern(s) tried: ['app/$show/']

my url tag:

    <a href="{% url 'show' %}"> item </a>

url.py

    url(r'^app/$', include('app.urls')),

app.url.py

    url(r'^$', 'app.views.index', name='app_index'),
    url(r'^show/', 'app.views.show', name='show'),

What can be wrong? Been following the Django doucmentation and searched around the internet with no results.

Swallow
  • 69
  • 1
  • 13

1 Answers1

3

Its because you've included the $ in the regex that matches an include, you should remove this

url(r'^app/', include('app.urls')),

and add it to the end of show

 url(r'^show/$', 'app.views.show', name='show'),

The $ in a regex indicates the end of a line, which obviously isn't the case when you're intending to build upon it with an include.

Sayse
  • 42,633
  • 14
  • 77
  • 146