I am trying to display all users in a User object without knowing the structure of the object (so I can use the same table to display a different collection of objects).
This is what it will look “statically”:
<table>
<tr>
<td>id</td>
<td>username</td>
</tr>
{% for item in entities %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.username }}</td>
</tr>
{% endfor %}
</table>
What I would like to do is something like this (this is just to show what I'm trying to do, but it is not even close to work):
<table>
<tr>
{% for property_title in entities.item[0] %}
<td>{{ property_title }}</td>
{% endfor %}
</tr>
{% for item in entities %}
<tr>
{% for property in item %}
<td>{{ property.value }}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
The result should be as follows:
<table>
<tr>
<td>id</td>
<td>username</td>
</tr>
<tr>
<td>1</td>
<td>Mike123</td>
</tr>
<tr>
<td>2</td>
<td>jesica2</td>
</tr>
</table>
PD: this is my first post, so I apologize if I missed something.
source
share