Federico De Marco
Federico De Marco

Reputation: 341

Django, how to fix max decimal in floatfield in annotate?

I have the following code:

annotate(totale=ExpressionWrapper(Sum(F('prezzo')*0.50/12),output_field=FloatField()

but in my template I have as results (for example) 145,555555555555555555555555 instead 145,55

I have added |intcomma but the result is the same.

How could I fix this ??

Upvotes: 0

Views: 169

Answers (1)

bmons
bmons

Reputation: 3392

you can do it with float format

{{ value|floatformat:2 }}

Upvotes: 1

Related Questions