python - how part queryset in Temokate -


got code on python 2.7 user django how can parse dishs_list in template?

userorder = userorder.objects.filter(user_id=self.request.user.id,                                              is_closed=0) dishs = userorderitem.objects.filter(order_id=userorder[0].id).values('dish_id') \             .annotate(count=count('dish_id'))  dishs_list = list() d in dishs:     dish = dish.objects.filter(id=d['dish_id'])     shop = shop.objects.filter(id=dish[0].shop_id)     dishs_list.append([d, dish, shop]) 

have print(dishs_list)

[[{'count': 8, 'dish_id': 1}, <queryset [<dish: Суши>]>, <queryset [<shop: Суши Ями>]>], [{'count': 5, 'dish_id': 2}, <queryset [<dish: Муши>]>, <queryset [<shop: Суши Ями>]>]] 

{% dash_item in dash_list %}{{dash_item.0.count}}{{dash_item.0.dash_id}}{{dash_item.1}}{{dash_item.2}}{% endfor %}

here {{dash_item}} again list used {{dash_item.0}} first element , {{dash_item.1}} , {{dash_item.2}} 2nd , 3rd items respectively.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -