Reputation: 1113
I'm using django_table2 to display data from a mysql database. One of the columns is a text column. Data from the text column is displayed without any line breaks. I know django has the linebreaks
filter. My template just does {% render_table table %}
so using that filter is not an option. django_tables2 has several options for different column types like tables.BooleanColumn
but I don't see an option for text columns. All I'd really like to get is the line breaks to work correctly.
Upvotes: 0
Views: 1115
Reputation: 15084
You can use the TemplateColumn
to render any custom template in a column - for example, if you want to use the linebreaks template filter, try something like this:
class MyTable(tables.Table):
text_field = tables.TemplateColumn('{{ record.text_field|linebreaks }}')
...
Upvotes: 5