3

Here's a hack I'm currently using:

class ProductMaxIPPortEldCountMonthlyTable(tables.Table):                      
    ip_count = tables.TemplateColumn('{% load humanize %}{{ record.ip_count|intcomma }} ')

I'm using django.contrib.humanize. Is there a cleaner way to achieve this effect?

d33tah
  • 10,999
  • 13
  • 68
  • 158

1 Answers1

4

You can import the intcomma template filter, and define a custom render method for the column that uses it.

from django.contrib.humanize.templatetags.humanize import intcomma

class ProductMaxIPPortEldCountMonthlyTable(tables.Table):                      
    ip_count = tables.Column()

    def render_ip_count(self, value):
        return intcomma(value)
Alasdair
  • 298,606
  • 55
  • 578
  • 516