JayB
JayB

Reputation: 77

Django URL Page error when link is clicked twice

I have a url defined as:

path("home/projects/",project_view,name = "viewProject")

This render correctly when i click on the 'Details' link on project_view.html

<li>
  <a href="projects" data-toggle="tooltip" class="tip-bottom" title="All Projects">
  <i class="fa fa-list" aria-hidden="true">Details</i></a>
</li>

But while i am on the same page,if i click the same link again i get an error:

home/projects/ [name='viewProject']

"Page not found...The current path, home/projects/projects, didn't match any of these"

I understand what the error means,but how can i redirect the page to "home/projects/" if the link is clicked twice?

Upvotes: 0

Views: 520

Answers (1)

Arjun Shahi
Arjun Shahi

Reputation: 7330

Instead of writing the url patterens you should use the django url template tag like this:

<a href="{% url 'viewProject' %}" data-toggle="tooltip" class="tip-bottom" title="All Projects">
  <i class="fa fa-list" aria-hidden="true">Details</i></a>

Upvotes: 2

Related Questions