I'm trying to use this code snippet in a Django project.
How can I access each key's value (the list)?
And show the list items?
I want to display a table like this using Jinja. Is it possible?
| key | values |
|---|---|
| 100 | 1,2 |
| 200 | 3,4 |
| 300 | 5,6 |
| 400 | 7,8 |
There can be thousands of rows in the table.
def index(request):
data = {
100: [{'childId': 1, 'childStructure': 'Leaf'}, {'childId': 2, 'childStructure': 'Intermediate'}],
200: [{'childId': 3, 'childStructure': 'Intermediate'}, {'childId': 4, 'childStructure': 'Leaf'}],
300: [{'childId': 5, 'childStructure': 'Leaf'}, {'childId': 6, 'childStructure': 'Intermediate'}],
400: [{'childId': 7, 'childStructure': 'Intermediate'}, {'childId': 8, 'childStructure': 'Leaf'}],
}
return render(request,'index.html', {'data': data})