Blog available for sell
This blog is available for sale. Please 'contact us' if interested.
Advertise with us
django-error   13   130018
Solving Django error 'NoReverseMatch at' URL with arguments '()' and keyword arguments '{}' not found.

Every Django developer encounters below error at least once in their life for sure.

NoReverseMatch at /url_path/ Reverse for 'url_name' with arguments '()' and keyword arguments '{}' not found. n pattern(s) tried: []

Beginners spend many hours debugging the issue, jumping from question to question on Stackoverflow and posting in multiple groups on Facebook. In this article we have tried to list all the common mistakes developer makes which leads them to above error.

What is this error:

First lets see what this error is trying to tell developer.

Django is trying to find a URL with name 'url_name' and it is not able to find any pattern match.

Application traverses the file from top to bottom and match the pattern. It stops at first successful match.

Arguments '()' and keyword arguments '{}' means that the URL application is searching for have no arguments or keyword arguments in it.

Application tried to match against 'n' patterns.

Why this error:

Lets say we have below file.

from django.urls import path

from . import views

app_name = 'polls'
urlpatterns = [
    path('articles/<int:year>/', views.year_archive, name='news-year-archive'),

In above configuration:

  • URL path is articles/<int:year>/ , like /articles/2018/
  • Function name in  file is year_archive
  • URL name is news-year-archive

Main reasons behind this error are:

1) Using wrong URL name in template html file.

For example in below template code snippet,

<a href="{% url 'news-year-archive' 2012 %}">2012 Archive</a>
instead of using news-year-archive are you using news-year-archives  

2) Commented HTML code.

Django tries to parse the template tags in commented HTML code as well while trying to render the template.

If all the url template tags in your template are correct, check the commented part as well.

If there is any error in commented part, remove it.

<a href="{% url 'news-year-archive' 2012 %}">2012 Archive</a>
<!-- <a href="{% url 'news-year-archives' 2012 %}">2012 Archive</a> -->
In the snippet above, application will throw the error for second line as there is no URL with name 'news-year-archives '.  

3) Arguments or Keyword arguments

Make sure you are passing the correct number of Arguments or Keyword arguments in URL template tag.

As you can see in file, URL with name 'news-year-archive ' expects an argument 'year' in it. If you are not passing the year in url template tag, application will throw the error. 


<a href="{% url 'news-year-archive' %}">2012 Archive</a>

should be

<a href="{% url 'news-year-archive' 2012 %}">2012 Archive</a>

4) Including app URL conf in project

Make sure you have included the app urls in project file.

from django.urls import include, path
from django.contrib import admin

urlpatterns = [
    path('app_name/', include('app_name.urls', namespace="app_name")),

5) Namespace

URL namespaces allow you to uniquely reverse named URL patterns even if different applications use the same URL names.

For example app1 have URL name 'contacts', now app2 can also have URL with same name provided we are using namespace while including URLs in project's file.

In the template snippet inside url  template tag, we are using namespace:url_name syntax

<a href="{% url 'app_name:news-year-archive' 2012 %}">2012 Archive</a>

6) Incorrect RegEx

If you are using any regular pattern in your URLs, make sure it is correct. In below URL page_number should consist only digits (\d+).

re_path(r'comments/(?:page-(?P<page_number>\d+)/)?$', comments)

7) Django Version

In Django 1.10, the ability to reverse a URL by its python path was removed. The named path should be used instead.  

If your application is still throwing this error, comment here and we will help you sail through this.  

Host your Django Application for free on PythonAnyWhere. If you want full control of your application and server, you should consider DigitalOcean. Create an account with this link and get $100 credits.

django-error   13   130018
13 comments on 'Solving Django Error 'Noreversematch At' Url With Arguments '()' And Keyword Arguments '{}' Not Found.'
Login to comment

Aditya Vikram Monga Aug. 24, 2018, 9:37 a.m.
I was going out of my mind trying to find the error. Option 2 -> Django parses HTML comments too. I had an old not updated url in my template comments.Bless you, good person.
Nikita Dec. 21, 2018, 2:16 a.m.
Very good stuff! Thank you!You saved me a second half of day.
Richfield Feb. 2, 2019, midnight
thanks alot i just got it fixed by changing my url to path from django.urls
Akhil Adiga June 6, 2019, 5:20 a.m.
Hello guys, I was getting the same error, as I am a newbie I read all the possible solutions and tried to figure out the problem, but couldn't do it, can you guy help me Here is the codeApp name is listings, urlpatterns = [ path('', views.index, name='listings'), path('<int:listing_id>', views.listing, name='listing'), path('search',, name='search'),]TEMPLATE FILE <a href="{% url 'listing' %}" class="btn btn-primary btn-block">More Info</a>
Shengz Oct. 30, 2019, 1:04 p.m.
Thank you.why does Django check comments too? this is literally killing people, at least me.
Mark Dec. 4, 2019, 2:38 p.m.
Thank you, your point number 2 literally saved my life. well almost.
Karthika March 3, 2020, 11:54 a.m.
NoReverseMatch at /reports/Reverse for 'getreport' with keyword arguments '{'environment': None, 'clientname': ''}' not found. 1 pattern(s) tried: ['reports\\/\\/(?P<environment>[^/]+)\\/(?P<clientname>[^/]+)\\/$']I am getting the above error please help me out
Anwar Tuha May 5, 2020, 6:49 a.m.
Nice...solution 2 worked for me....
Vially June 12, 2020, 7:50 a.m.
THERE IS ANOTHER INSTANCE NOT MENTIONED HERE IN THE ARTICLE THAT CAN CAUSE THIS HEAD ACHEif you put a reverse url name as the link of let's say a Back button that takes you back to the page details of the post you wanted to edit, you will get error when trying to access that page own url name. and it confusing because you are trying to access a specific url but the error thrown is the error of a different url (in this case the reverse url present on that template in the back button).
Azzam Makki June 22, 2020, 2:28 p.m.
Admin thank you very much , your articles are great value to the community !!
Precious Oct. 9, 2020, 7:25 a.m.
Wow I'm following you guys up ASAP,you just solved a problem I battled with over night
Anupam Saxena Nov. 4, 2020, 11:28 a.m.
I am still getting the is the error:Error during template renderingIn template C:\Users\lenovo\projects\mysite\polls\templates\polls\detail.html, error at line 5Reverse for 'vote' with arguments '('',)' not found. 1 pattern(s) tried: ['polls/(?P<question_id>[0-9]+)/vote/$']1 <h1>{{ question.question_text }}</h1>2 3 {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}4 5 <form action="{% url 'polls:vote' %}" method="post">6 {% csr
Kenneth Nov. 13, 2020, 8:46 p.m.
Yo thanks for saving me a sleepless night...honestly dint knw comments r parsed too...thanks alot

Related Articles:
Solving Django Error: TemplateDoesNotExist at /app_name/
How to solve TemplateDoesNotExist error in Django projects, reason for TemplateDoesNotExist error in Django, fixing TemplateDoesNotExist error in Django...
Displaying custom 404 error (page not found) page in Django 2.0
How to create custom 404 error page in Django, Handler404 example Django 2.0, Page not found error in Django 2.0, Custom Error handlers in Django 2.0...
Designing custom 404 and 500 error pages in Django
How to create your own awesome 404 error or 500 error page in django. Step by step guide to help you design your own 404 not found error page in Django. Design your own 500 internal server error page in Django application...
DigitalOcean Referral Badge

© 2022-2023 Python Circle   Contact   Sponsor   Archive   Sitemap