3
Caught NoReverseMatch while rendering: Reverse for 'views.main' with arguments '()' and keyword arguments '{}' not found.

I don't understand what would cause the error.

My urls

urlpatterns = patterns('',
url(r'^$', views.main),

html template

<a href="{% url views.main %}"> bla bla blah</a>

And in my views.py

return render_to_response("main.html", d, context_instance=RequestContext(request)) 

I've checked my TEMPLATE_DIRS and they seem to be pointing to the correct directory.

bdd
  • 3,436
  • 5
  • 31
  • 43

4 Answers4

4

The likelihood is that you have an error somewhere else, which is preventing one of your views from being imported - probably a dependency missing on your production server. The reverse-URL functionality works by importing all your views, so if any of them can't be imported for any reason you'll see a NoReverseMatch error.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • It wasn't a missing dependency. Indeed, I have no idea what was causing the problem. I did a refresh of my production image and was able to get rolling just fine. I wish I had more to report back to future SO'ers. – bdd Dec 05 '10 at 00:49
1

Try:

url(r'^$', views.main, name="main-view")

and on template:

<a href="{% url main-view %}"> bla bla blah</a>
user432567
  • 11
  • 1
0

Restarting gunicorn service solved my problem:

sudo systemctl restart YOUR_GUNICORN.service

Make sure that you are restarting the right gunicorn service. I was driving myself insane, and then I realized I was restarting the wrong service. You might also try restartingrestart nginx, but it shouldn't be necesary: sudo systemctl restart nginx

toto_tico
  • 17,977
  • 9
  • 97
  • 116
0

I ran into the same thing, and so I tried Paperino's method of creating an image of the server and then restoring the server to that image, and voila, the template error went away. I have no idea why that works, but it did for me, so I'm not complaining, spent most of the day trying to figure this one out :)

vectorfrog
  • 1,353
  • 8
  • 13