How to format a float number in Python Flask and Jinja? -


i've googled , searched here can't find explanation understand. i've got value gets passed html template value 53.0 obtained 3rd party api.

my code is:

£{{product_details.unitprice}} 

which displays £53.0, there way of formatting 2 decimal place float correctly reads £53.00.

i have tried reading instructions here github don't understand them. i'm trying avoid formatting each variable separately in actual python code or wrong approach?

i'm editing question because per comment:

£{{product_details.unitprice|float}} 

didn't make difference , don't understand link given.

thanks jake explained

{{'%0.2f'|format(product_details.unitprice|float)}} 

is correct format 2 decimal places.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -