-2

I'm trying to format these numbers. Example:

24.324324324324323

18.91891891891892

I want to delete the numbers behind it to be like this

24.3

18.9

what can use django template tags? or using some code?

Community
  • 1
  • 1
  • If you want to round, django has the floatformat filter (https://docs.djangoproject.com/en/2.0/ref/templates/builtins/#floatformat). However if you wish to truncate, it looks like there is no built in options. Although this may be useful: https://stackoverflow.com/questions/27778986/truncate-decimal-numbers-of-floatfield-always-rounding-down – tim-mccurrach Jan 27 '18 at 20:29
  • Possible duplicate of [Python Decimals format](https://stackoverflow.com/questions/2389846/python-decimals-format) – Gershon Papi Jan 28 '18 at 01:13

1 Answers1

0

You can use floatformat filter tag in your template , here is an exampe:

value = 12.3436547654756756    

{{ value|floatformat }} =====> 12.34