Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

75
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda