Multiplication in Django view -
i trying represent decimal values percentages in template. specifically, have several fields in model values such '0.4000000059604645'. in models.py have representated as
information_percent = models.floatfield(blank=true)
and in view have:
org = organizationaldata.objects.get(name=organization) information_percent = org.information_percent
what cannot figure out how show as, instance, '40.0' in template. have done lot of searching , can't figure out how multiply value 100, or other technique deliver intended result.
and suggestions appreciated.
sounds need built-in floatformat template filter.
for example:
views.py
org = organizationaldata.objects.get(name=organization) information_percent = 100 * org.information_percent
template.html
<span>info percent: {{ information_percent|floatformat:1 }}</span>
Comments
Post a Comment