Home>

In tagsmeterworks, but there is no way to show % completion on the progress bar itself.

How to show the percentage of completion on a dynamic progress bar,bootstrap + python?

Making calculations in views

object['meter']= []
if i.end_start1 > dt:
  object['meter'].append(100 -((i.end_start1-dt).total_seconds()/(i.end_start1-i.start_data1).total_seconds())*100)
else:
  object['meter'].append(100)

Passing to html

<td>  {% if i.met1 != '9999' %}
  <div class="progress">    <div class="progress-bar bg-success" role="progressbar" aria-valuenow="{{ i.meter.0 }}" aria-valuemin="0" aria-valuemax="100">    </div>  </div>  {% endif %}
</td>
  • Answer # 1

    I solved the problem:

    for i in range(len(object['meter'])):
      object['meter'][i]= round(object['meter'][i])
    

    and divs in html:

    <td>  {% if i.met1 != '9999' %}
      <div style='width: 50px; background color: white height: 25px;'>    {{ i.meter.0 }}%
        <div style='width: {{ i.meter.0 }}%; background-color: green; height: 25px; margin-top: -24px;'>    </div>  </div>  {% endif %}
    </td>