Emile
Emile

Reputation: 3484

Django Caught NoReverseMatch - TemplateSyntaxError

I got this error, but can't seem to figure it out. I copied it directly from a previous Django project, hence part of the confusion.

TemplateSyntaxError at Caught NoReverseMatch while rendering: Reverse for 'about' with arguments '()' and keyword arguments '{}' not found.

In my index.html, I have a link to {% url about %} didn't link to the about.html template

Urls.py has this:

urlpatterns = patterns('django.views.generic.simple',
    url(r'^about/$', 'direct_to_template', {"template":"about.html"}, name="about"),
)

Upvotes: 3

Views: 4040

Answers (3)

Emile
Emile

Reputation: 3484

The problem was my second urlpattern was overriding the first pattern.

Instead of:

urlpatterns = patterns('',

it needed to be:

urlpatterns += patterns('',

Upvotes: 4

culebrón
culebrón

Reputation: 36513

Your url is ok. You need to check two things:

  1. Is the urls.py included from the main urls.py?
  2. Is the application added to INSTALLED_APPLICATIONS in settings.py?

Upvotes: 0

Arthur Debert
Arthur Debert

Reputation: 10697

The url regex is expecting an ending slash. Does the offending url end with a slash?

If you do have a PREPEND_SLASHES settings differing from your last projects, that might explain the error you're seeing!

Upvotes: 0

Related Questions