You'll have to choose width and or height as limiting factors for your columns. Assuming you can't dictate the content length, you could choose truncating what is shown.
as shown in Set the table column width constant regardless of the amount of text in its cells? and Using CSS to create table cells of a specific width with no word wrapping , it is hard or impossible to set the table column width directly without fiddling with the table layout and width settings; alternatively, you could wrap every content in a div, and then apply your formatting to those divs.
To achieve this in tables2, I overrode the table.Column:
class DivWrappedColumn(tables.Column):
def __init__(self, classname=None, *args, **kwargs):
self.classname=classname
super(DivWrappedColumn, self).__init__(*args, **kwargs)
def render(self, value):
return mark_safe("<div class='" + self.classname + "' >" +value+"</div>")
create the column in the table:
custom_column = DivWrappedColumn(classname='custom_column')
and then apply the css:
div.custom_column {
white-space: normal;
width: 200px;
height: 45px;
}
This results in a fixed-width, fixed height cell that wraps until there are no more rows and then truncates.
Alternatively, use "white-space: nowrap", and omit the height; then the cell is just truncated (but users can scroll).