Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Converting string to integer without losing the decimals number(s)

I am trying to convert a string in to an integer in a Jinja template without losing the decimal numbers

I tried the following code which partially works;

{{myfield|int}}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The problem is that I loose any decimal numbers (5.5 becomes 5 for example) is there a way to fix this?

>Solution :

You can use float instead of int:

{{myfield | float}}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading