Iterating through json list in Django template

Viewed 407

I am passing the following context in my Django template :

context = {'test': custom_json_list}

And the output of custom_json_list is this :

{'pc_16530587071502': [{'people_count_entry__sum': None}],
 'pc_17100675958928': [{'people_count_entry__sum': None},
                       {'people_count_entry__sum': None},
                       {'people_count_entry__sum': None},
                       {'people_count_entry__sum': None},
                       {'people_count_entry__sum': None},
                       {'people_count_entry__sum': None},
                       {'people_count_entry__sum': None},
                       {'people_count_entry__sum': None},
                       {'people_count_entry__sum': 4},
                       {'people_count_entry__sum': None},
                       {'people_count_entry__sum': None},
                       {'people_count_entry__sum': None},
                       {'people_count_entry__sum': None},
                       {'people_count_entry__sum': None},
                       {'people_count_entry__sum': None},
                       {'people_count_entry__sum': None}]} 

I want to display the data in the following format:

'pc_16530587071502' : NONE
'pc_17100675958928' : None
'pc_17100675958928' : None
'pc_17100675958928' : None
'pc_17100675958928' : None
'pc_17100675958928' : None
'pc_17100675958928' : None
'pc_17100675958928' : 4
'pc_17100675958928' : None
'pc_17100675958928' : None
'pc_17100675958928' : None

How can I proceed with the syntax so that I can see the data in this format.

The only thing I was able to decipher is this :

{% for key, value in test.items %}
     {{ key }} <br />
     {{ value }} <br />
{% endfor %}

Thanks in advance.

1 Answers
Related