columns.py 487 B

123456789101112131415161718192021
  1. import django_tables2 as tables
  2. __all__ = (
  3. 'CommitRateColumn',
  4. )
  5. class CommitRateColumn(tables.TemplateColumn):
  6. """
  7. Humanize the commit rate in the column view
  8. """
  9. template_code = """
  10. {% load helpers %}
  11. {{ record.commit_rate|humanize_speed }}
  12. """
  13. def __init__(self, *args, **kwargs):
  14. super().__init__(template_code=self.template_code, *args, **kwargs)
  15. def value(self, value):
  16. return str(value) if value else None