Приложение Django - просмотр словаря с вложенными массивами

Я хотел бы просмотреть и отобразить этот словарь, который содержит другие подтаблицы внутри. Здесь я хотел бы отобразить только покупки "fafa". Views.py

def app(request):
 dict= {
    "toto": "tata",
    "messages": [
  {
   "mont": "ton",
   "fafa": "fki"
  }
],
 "commandes": [
  {
  "numero": "h221g",
  "date": "14-07-22",
  "reference": "ref1",
  "name": "fafa",
  "purchases": [
    {
      "article": "articlename",
      "designation": "laptop",
      "quantity": 2,
      "price": 133
    },
    {
       "article":"article2",
       "designation":"Dell"
       "quantity":3,
       "price":144
    },
    ...
  ]
 },
 ....
]
}
 mes_ventes=dict['commandes']
 purchases=dict['commandes'][0]['purchases']
 context={'commandes':mes_ventes,'lignes':mes_lignes}
 return render(request,'test/test.html',context)

test.html

{% for commande in commandes %}
    {% if commande.name == "fafa" %}
        {% for ligne in lignes %}
            <p>{{ligne.article}}<br>{{ligne.designation}}<br>
                {{ligne.quantity}}<br>
            {{ligne.price}}</p>
        {% endfor %}
    {% endif %}
{% endfor %}

Я получаю покупки, но не покупки "fafa"

Вернуться на верх