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

499
Views
Pase Array usando AJAX en Django

Tengo una matriz llamada métricas y estoy tratando de pasarla al backend con AJAX, pero solo obtengo los últimos valores de la matriz 7,8,9 . Quiero recoger toda la matriz. ¿Alguna idea de cómo? Cualquier ayuda es apreciada.

html

 var metrics = [ [1,2,3], [4,5,6], [7,8,9], ]; $.ajax({ type : 'GET' , url : "...", data : {"metrics[]": metrics }, })

vistas.py

 def Sensor_Metrics(request): if request.is_ajax and request.method == "GET" : metrics = request.GET.get("metrics[]") print(metrics) return JsonResponse({"error": ""}, status=400)
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

La solución es agregar los corchetes en views.py al llamar a la solicitud.

en guión

 var metrics = [ [1,2,3], [4,5,6], [7,8,9], ]; $.ajax({ type : 'GET' , url : "...", data : {"metrics": metrics}, })

en vistas.py

 def Sensor_Metrics(request): if request.is_ajax and request.method == "GET" : metrics = request.GET.get("metrics[]") #Important print(metrics) return JsonResponse({"error": ""}, status=400)

De nada

over 4 years ago · Santiago Trujillo Report

0

En las vistas, debe usar request.GET.getlist para obtener la lista completa de la solicitud. Debe usar -: metrics = request.GET.getlist("metrics[]") . Puede consultar los documentos aquí .

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!