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

183
Views
mientras se trabaja para contenido dinámico en django, el código javascript escrito solo funciona con el primer elemento del ciclo

Aquí está la plantilla HTML donde se implementa el código javascript dentro del bucle for. Estoy tratando de tomar los datos requeridos de los modelos Django.

 {% for other_campaign in other_campaigns %} <div class="container" style="background-color:#f1f1f1"> <div class="row"> <div class="column-33"> <img src="{% if other_campaign.Image %} {{other_campaign.Image.url}} {% else %} {% static './Images/blank.jpg' %} {% endif %}" class="camp_img" alt="App"> </div> <div class="column-66"> <a href="{% url 'detail' other_campaign.id %}" class="victim"><b>Victim: {{other_campaign.Name}}</b></a> <div class="target"><b><i>Target Amount:</i> {{other_campaign.Target}}</b></div> <div class="target"><b></b><i>Collected Amount:</i> {{other_campaign.Collected}}</div> <br> <p><b>Info: {{other_campaign.Info}}</b></p> <br> <div class="progress"> <div class="progress-bar" role="progressbar" style="width: 25%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"></div> <br> </div> <div class="progress_text">Rs. {{ other_campaign.Collected }} - Done</div> <br> <br> <button class="button"><a href="#" class="donate_here">Donate Here</a></button> <br> <div style="float: right;">Date_added: {{other_campaign.Date_added}}</div> </div> <br> </div> </div>

aquí está el código javascript

 <!-- progress bar script --> <script> const progress = document.querySelector(".progress-bar") const progpercent = {{other_campaign.Collected}}/{{other_campaign.Target}}; progress.style.width = `${progpercent * 100}%`; </script> {% endfor %}

Y aquí está la imagen de salida en el sitio web.

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