5

I have this variable:

{{ object.article.rating.get_percent|floatformat }}

that outputs this:

540787

Is there a way to format it so it shows as:

540,787 
Tommy
  • 1,727
  • 3
  • 13
  • 9
  • 1
    Like this? http://stackoverflow.com/questions/1823058/how-to-print-number-with-commas-as-thousands-separators-in-python-2-x – tMC Jun 07 '11 at 20:00
  • @tMC no I was hoping to do it from a template level. I don't have access to the python code. – Tommy Jun 07 '11 at 20:03

1 Answers1

12

this should help you out: http://twigstechtips.blogspot.com/2010/02/django-formatting-numbers-with-commas.html

details: add "django.contrib.humanize" to your INSTALLED_APPS setting.

then in the template:

{% load humanize %}
{{ price|intcomma }}
rolling stone
  • 12,668
  • 9
  • 45
  • 63