I am using django-tables2 and I have a field that has really long text.
Which I would like to truncate like this:
It is a bootstrap table:
class EntryRecordTable(tables.Table):
...
comment = tables.Column(accessor=A('Comment'))
class Meta:
template_name = 'django_tables2/bootstrap-responsive.html'
attrs = {'class': 'table table-bordered'}
orderable = False
empty_text = 'No entries for selected dates'
I have tried this answer about truncating text in a bootstrap table, but it makes all rows a single line and truncates a bit too much. How can I do this in code?
I am using truncatewords combined with tooltip:
comment = tables.TemplateColumn('<data-toggle="tooltip" title="{{record.comment}}">{{record.comment|truncatewords:5}}')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With