我在写一个views时候,要在模板里多重循环。。
一个是订单表,一个是产品表,其中产品表和订单表中只有一个order_id进行关联。
现在我想循环 订单表的时候,同时循环出该订单所有产品。
我代码是这样写的
orderList = Orders.objects.filter(shop_id__in=List)
for orderCountry in orderList:
productList = Products.objects.filter(parent_id = orderCountry.order_id)
orderCountry.country = Country.objects.get(country_code=orderCountry.country).country_zh_name
orderCountry.shop_id = aliexpressToken.objects.get(resource_owner = orderCountry.shop_id).shop_name
这样的话,无法在模板页面循环出来