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

232
Vistas
How to send data with Url Django

I want to send {{order.id}}, but getting error like pictuce in bellow, please helping me to solve problem

Image Error

View.py

def Detail_pem(request, idor):
    print(idor)
    return render(request, 'store/detail.html' )

pemby.html

              <!-- <a href="{% url 'Detail_pem' %}"><button data-product="{{order.id}}" data-act="{{order.name}}" class="btn btn-warning id_order btntam" >Detail</button> </a> -->
              <button data-product="{{order.id}}" data-act="{{order.name}}" class="btn btn-warning id_order btntam" >Detail</button> 
              <a href="{% url 'Detail_pem' idor=order.id %}"></a>
            </td> 
          </tr>
          {% endfor %}
        </tbody> 
      </table>
</div> 
<!-- <script type="text/JavaScript" src="{% static 'js/pem.js' %}"></script> -->
 
<script>
var id_order = document.getElementsByClassName('id_order')
for (i = 0; i < id_order.length; i++) {
  id_order[i].addEventListener('click', function(){
        var orid  = this.dataset.product
        var ornm  = this.dataset.act
        console.log('orid :', orid)
        console.log('ornm :', ornm)
        window.location.href = "{% url 'Detail_pem'  %}"
    })
    
}

urls.py

path('Detail_pem/<idor>', Detail_pem, name='Detail_pem'),
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you are redirecting

window.location.href = "{% url 'Detail_pem' %}" without a variable

but in your urls.py you are passing idor variable

it should be: window.location.href = "{% url 'Detail_pem' order.id } %}"

and your urls.py change to this: int:id

#if you are passing integer
path('Detail_pem/<int:id>', Detail_pem, name='Detail_pem'),

#or if you are passing string
path('Detail_pem/<str:id>', Detail_pem, name='Detail_pem'),

also please do not attach screenshots with errors, you need to attach code itself

about 4 years ago · Juan Pablo Isaza 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