I am trying to create a generic table (that I can reuse for other Objects as well) by passing in the views the context "table"
As part of view.py I have the following information passed on as Context:
- object_list = User.objects.all()
- table.columns that contains the Column Accessor (the property of the User object I want to access) and the Header Name e.g. {'last_name': 'Last Name', 'first_name': 'First Name'}
In my template I want to loop through the objects, and find the "Column Accessor" and get the property of the object. So far I have the following, but I am not sure how I can access the property of the object from the template. I can imagine I could create a filter tag, but any help on how to accomplish that would be appreciated.
#template.py
{% for object in object_list %}
{% for column in table.columns %}
<td>{{object.????}}</td>
{% endfor %}
{% endfor %}