Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

NoReverseMatch Debugging

In this lesson, you’ll review what you just saw and practice some more debugging by looking at error messages in Django and get some tips on how to debug a NoReverseMatch error. If you get a NoReverseMatch error, there are a few files you’ll want to check:

  • urls.py: Make sure you have an app name defined as well as a name for your path so you can build valid namespaces.

  • your_template.html: If you’re using URL linking, make sure that the string that you’re using is a valid Django namespace with the name of the app as well as the path. Also make sure that you have an argument that you’re passing correctly, with a space right after the namespace.

Comments & Discussion

reblark on Nov. 13, 2019

Things above are things that I did a “million” times. When I finally found the problem, it was a typo in PyCharm, my typo. I could not see it because of the layout of the frame in PyCharm. Trust me, I went over my code character by character. I finally found it by looking at the error messages many times and they simply told me that I wasn’t passing the right address, but from my perspective I was passing a hard code number or project.pk…Looking more deeply into the error message, I found a display of my code. When I saw it, I thought “that isn’t my code, that’s crazy.” Of course, it was my code. So, I went back to PyCharm and scrolled up and down, left and right. I found it. I couldn’t believe it. It was a result of not paying attention to auto completion and winding up with two extra }}s. That’s all it was and it took me 2 hours of work and two or three messages to you. I would like to make a suggestion. This video is good but only as far as it goes. I did everything this video suggest several times and did not find the error. That’s simply because there is more to debugging than this. As I have mentioned previously, I really like your pressing the point that error messages are your friends. However, one needs to read the messages thoroughly. Just knowing that it’s a “NoReverseMatch” error is incomplete. I would emphasize always, always, looking for typo errors in your code. I just happen to be a very smart guy and an excellent typists. Throughout this course I have been stunned and amazed at the number of either careless, sloppy or stupid mistakes I have made, not in the coding, but in the typing. Dan even sent me a note about one. I have learned a lot from this course about how bad my coding is, not from a theory and rules standpoint. As I improve my typing/coding I will get better and better. I think there may be others who have this particular problem and it might be good to emphasize that as part of your excellent focus on “errors are your friends” message. Cheers, Martin. and, thanks again.

Martie on May 13, 2020

I got a bit lost earlier on with the views.py code. On the video at about 1:45 you show the “def project-detail()” function. Everywhere else the .html template is named the same as the function but you have used project_detail() as the function and details.html as the template :-). Obviously not wrong, but a challenge to spot.

Is there in fact though an error in the code in the return render() line where at 1:45 your code shows

{'projects': project})

as opposed to

{'project': project})

Martin Breuss RP Team on May 14, 2020

Hi @Martie! Yes, thanks for noting that. This is indeed a typo. I believe it pops up in another slide too and we’ve added a note there, but missed it here! I’ll look to it that we get an alert box up in the video description to avoid this from causing confusion. Thanks again! :D

Become a Member to join the conversation.