[Not really sure if the topic makes sense, but didn't found a more meaningful one.]
I've created a template which looks like:
{% for x in jobs %}
<table>
<tr>
<td></td>
<td>{{ x.Ecordov.oovorder }}</td>
</tr>
<tr>
<td></td>
<td>{{ x.ooaname1.split('{}')[0] }}</td>
</tr>
<tr>
<td></td>
<td>{{ x.ooaname2.split('{}')[0] }}</td>
</tr>
<tr>
<td></td>
<td>{{ x.ooazusatz.split('{}')[0] }}</td>
</tr>
</table>
{% endfor %}
As you can see, I'm getting a specific position in multiple lists, which works quite well.
The problem I'm trying to solve: These lists have up to 16 positions, which I have to render. I could of course copy/paste the above <tr> </tr> block 16 times into the template, and edit the line positions, but I'm quite sure that there is a better, more automated, way; however, I wasn't able to find this out on my own up until now.
Could anyone point me into the correct direction?
Thanks for any help and all the best!
getattr(x, attr)to grab the value within the attribute. Armed with this, you could do something likefor attr in ['ooaname1', 'ooaname2', ...], and simply do the rendering with{{ getattr(x, attr).split(....) }}. Ideally you want that list of attributes be stored in your code rather than the template for organization.