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

230
Views
Cómo enviar datos con Url Django

Quiero enviar {{order.id}}, pero obtengo un error como el de la imagen de abajo, por favor ayúdame a resolver el problema

error de imagen

Ver.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 answers
Answer question

0

estás redirigiendo

window.location.href = "{% url 'Detail_pem' %}" sin una variable

pero en tu urls.py estás pasando la variable idor

debería ser: window.location.href = "{% url 'Detail_pem' order.id } %}"

y tu urls.py cambia a esto: 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'),

Además, no adjunte capturas de pantalla con errores, debe adjuntar el código en sí.

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