utils.py 492 B

123456789101112
  1. def display(foods):
  2. """传递过来的结果集"""
  3. display_list = []
  4. childrens = []
  5. for food in foods:
  6. display_list.append({'id':food.id,'authName':food.authName,'path':food.path,'icon':food.icon,'partment_id':food.partment_id,'childrens':childrens})
  7. children = food.children.all()
  8. if len(children) > 0:
  9. # print(children,str(itm))
  10. childrens.append(display(food.children.all()))
  11. childrens = []
  12. return display_list