NoReverseMatch: Reverse with arguments and keyword arguments '{}' not found. 0 pattern(s) tried: []

July 10, 2016, 3:47 a.m.

Periodically, I get next error:

NoReverseMatch: Reverse for 'my_url_name' with arguments '(u'...',)' and keyword arguments '{}' not found. 0 pattern(s) tried: []

I do not understand quickly why my code is not works. Well, I write down this notes. Check list:

1. Include urls.py of app to project urls.py

urlpatterns = patterns('',
    ...
    url(r'^my_app/', include('my_app.urls')),
    ...
)

2. Include url to urls.py of app:

urlpatterns = patterns('',
    url(r'^my-url-name/(?P<my_object_id>\d+)/$', my_app.views.my_view, name='my_url_name'),
)

3. Add required arguments to urls.py

urlpatterns = patterns('',
    url(r'^my-url-name/(?P<my_object_id>\d+)/$', my_app.views.my_view, name='my_url_name'),
)

4. Add required arguments with call 'url' function in template or 'reverse' function in python code

# in template.html
<a href="{% url 'my_url_name' my_object_id %}">Do something</a>

# in python code
reverse('my_url_name', args=(my_object_id, ))

If your view doesn't provide arguments (such as my_object_id), then check the first two steps only.

Rate this article

0 from 5 (total 0 ratings)

You can send feedback, suggestions or comments on this article using this form:

Fields marked by star ( * ) is required.

Thank you for yor feedback!

After clicking the "Send" button, your message will be delivered to me on the mail.

Author of Article

Artem Maltsev

Web-developer, having the knowlenge of programming language - Python, framework - Django, content management system - Django CMS, platform of e-commerce site - Django Shop and many other applications, using this technologies.

The right to use content on this page https://vivazzi.pro/it/reverse-not-found/:

Permission is granted to copy an content with its author and reference to the original without using the parameter rel="nofollow" in tag <a>. Usage:

Author of Article: Artem Maltsev
Link to article: <a href="https://vivazzi.pro/it/reverse-not-found/">https://vivazzi.pro/it/reverse-not-found/</a>

More: Terms of site usage

Comments: 0

You can leave a comment as an unregistered user.

But if you sing up, you can:

  • receive notifications
  • view your comments
  • be able to use all the functions of the developed services

To comment in one's own name you should log in or sign up on Vuspace website

Send

There is no search on this site, so I offer to use usual search engine, for example, Google, adding "vivazzi" after your request.

Try it

Select currency for displaying monetary values