Reputation: 1225
I have an HTML table that contains a column named Attached Files. This column contains the name(s) of the attached documents. I want to be able to open these documents when they are clicked. But I cannot do this because the HTML table shows multiple file names in a single table cell. Here is how I get the file names from the PostgreSQL database.
{{for (i,e) in enumerate(rows):}}
<tr>
<td>{{=T("%(value_5)s") % dict(value_5=e.attached_files)}}</td>
</tr>
attached_files is the column name in my database. What I think I want to do is, separate/split the file names then apply HTML link using the href attribute.
My project is in Python (I don't want any JavaScript solutions).
Upvotes: 0
Views: 560
Reputation: 63737
e.attached_files
is a list which you are rendering (representing) as a list. Add one more loop to iterate over this list and represent each file as a table data within a table row
{{for (i,e) in enumerate(rows):}}
<tr>
{{for fname in e.attached_files:}}
<td>{{=T("%(value_5)s") % dict(value_5=fname)}}</td>
{{ pass }}
</tr>
if you do not want it on separate columns, place the fields on seperate spans within a table data
{{for (i,e) in enumerate(rows):}}
<tr><td>
{{for fname in e.attached_files:}}
<span>{{=T("%(value_5)s") % dict(value_5=fname)}}</span>
{{ pass }}
</td></tr>
Upvotes: 2