Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

84
Views
Dynamic link in Django always calls the first url path

In urls.py within urlpatterns I have below two lines

urlspatterns = [
...
path('<slug:productSlug>', ProductView.as_view(), name = 'viewProduct'),
path('<slug:boxSlug>', BoxView.as_view(), name = 'BoxView'),
...
]

In my html template I have two links

<a href="{% url 'viewProduct' item.productSlug %}" class="btn btn-outline-primary" tabindex="-1" role="button" aria-disabled="true">product view</a>

<a href="{% url 'BoxView' item.boxSlug %}" class="btn btn-outline-primary" tabindex="-1" role="button" aria-disabled="true">Box View</a>

The problem is even though I specified BoxView in the {% url 'BoxView' ... %} it keeps calling the viewProduct path. If I reverse the order of the two paths in urlPatterns then, it keeps calling the 'BoxView'. What I don't understand is it keeps calling whatever it finds first in urlPatterns.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You something to distingish between the view type. For example you could:

urlspatterns = [
...
path('product_view/<slug:productSlug>', ProductView.as_view(), name = 'viewProduct'),
path('box_view/<slug:boxSlug>', BoxView.as_view(), name = 'BoxView'),
...
]
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!