Skip to content
Advertisement

How to resolve “NoReverseMatch” Error in Django?

So I’m trying to create a table of hosts, and as one of the fields of that table include a clickable link to an update page. Which will pass the host_id to the update page. I was hoping someone could tell me what I’m doing wrong with regards to passing the correct parameter to upate/<host_id>. As I’m not quite sure as to how to fix the issue and make it so I can direct people via a clickable button in the table rendered to the appropriate update page. When I attempt to render the page with that added in I’m getting the following error:

JavaScript

It is also spiecificlly pointing to the following line of code as the issue:

JavaScript

This line is found in the following HTML segment. Relevant HTML Section

JavaScript

My urls.py section looks like the following. urls.py

JavaScript

Relevant Models.py

JavaScript

Relevant Views.py

JavaScript

Advertisement

Answer

Try something like this: Urls:

JavaScript

Template

JavaScript

As the other comment also mentioned, I don’t think re_path is the way to go

How to pass an id to a view as an argument in Django?

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement