83๐
โ
If you donโt care about the commas, then floatformat
will do the job:
{{ value|floatformat:"0" }}
If you do care about commas, you want:
{{ value|floatformat:"0"|intcomma }}
(Hat tip to Stephen for pointing me at intcomma
!)
๐คDominic Rodger
16๐
To use intcomma
filter, you should add django.contrib.humanize
to your INSTALLED_APPS
setting and {% load humanize %}
in a template.
๐คJim Sjoo
- [Django]-Django check if object in ManyToMany field
- [Django]-Django auto_now and auto_now_add
- [Django]-Django โ Login with Email
4๐
You can do it with the below on django, the argument โ0โ rounds it to exclude decimal places, but you can change it.
number = 7715.625
rounded_number = round(number,0)
๐คuser3655574
- [Django]-ImportError: Couldn't import Django
- [Django]-Django post_save preventing recursion without overriding model save()
- [Django]-Django using get_user_model vs settings.AUTH_USER_MODEL
0๐
You just need to use the round function and there is no need to specify the digits either. By default it returns an integer from the given float value.
number = 7715.615
rounded_number = round(number)
๐คThe_phoenix
- [Django]-Automatically create an admin user when running Django's ./manage.py syncdb
- [Django]-Django โ Overriding the Model.create() method?
- [Django]-How to specify the login_required redirect url in django?
Source:stackexchange.com