Django server production throws "NoReverseMatch" when rendering, works on development

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

I do not understand what might 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 view.py

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

I checked TEMPLATE_DIRS and they seem to point to the correct directory.

+3
source share
4 answers

The likelihood that you have an error somewhere else that prevents the import of one of your views is probably a dependency on your production server. The return URL function works by importing all of your views, so if any of them cannot be imported for any reason, you will see an error NoReverseMatch.

+4

Try:

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

:

<a href="{% url main-view %}"> bla bla blah</a>
+1

, Paperino , , , . , , , , :

0

gunicorn :

sudo systemctl restart YOUR_GUNICORN.service

, gunicorn. , , . nartx, : sudo systemctl restart nginx

0

Source: https://habr.com/ru/post/1778517/


All Articles