Humanizing django-tables2 output?

Here's the pen I'm currently using:

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

      

I am using django.contrib.humanize

. Is there a cleaner way to achieve this effect?

+3


source to share


1 answer


You can import a filter intcomma

and define a personalized rendering 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)

      

+3


source







All Articles