0

I have the json value in my django template and I need to loop for every value inside it.

{
    "hits": [
       {
        "_index": "catalog",
        "_type": "mobiles",
        "_id": "2e4d3356-95eb-4cc2-b4be-f75baa55248f",
        "_score": 1,
        "_source": {
            "name": "Apple iPhone 5S 16GB Space Grey",
            "product_score": "109",
            "product_rating": {
                "avg": "5",
                "count": "1"
            }
        }
       }
   ]
}

How should I iterate inside "_source"?

This code doesn't work:

{% for i in hits.items %}
<div>{{i}}</div>
{% endfor %}

The primary doubt is how to loop inside "_(underscore)" element

Sumit Sahay
  • 504
  • 4
  • 22

0 Answers0