I have this array structure payment_list['seller']['order'] that contains an Order object and payment_list['seller']['orders_detail'] that contains a list of OrderDetail objects.
In views.py no problem to access to the elements, but in template I am capable to access only to the first element, and I need to access to Order object and to the OrderDetail list.
In views.py - NO PROBLEM
for order in orders:
payment_list[order.seller] = {}
payment_list[order.seller]['order'] = order
payment_list[order.seller]['orders_detail'] = []
orders_detail = OrderDetail.objects.filter(order=order)
for od in orders_detail:
payment_list[order.seller]['orders_detail'].append(od)
for pa in payment_list:
print pa
print payment_list[pa]
print payment_list[pa]['order']
for od in payment_list[pa]['orders_detail']:
print od
In template.html - PROBLEM Impossible to access to the elements
1 way:
{% for pa, value_list in payment_list.items %}
{{ pa }}<br> OK
{% for value in value_list %}
{% if value == 'order' %}
ORDER:{{ value }}<br>
{% endif %}
{% if value == 'orders_detail' %}
DETAIL:{{ value }}<br>
{% endif %}
{% endfor %}
{% endfor %}
2 way:
{% for pa in payment_list %}
seller:{{ pa }}<br> OK
order:{{ payment_list.pa }} It doesn't show anything
{% endfor %}
I am sure it is a little thing, I forgot something? Is the sintaxis bad?
Thank you!