Django concatenate two querysets for same model

前端 未结 2 788
[愿得一人]
[愿得一人] 2021-01-20 21:28

I have a list of Products, each belonging to a different Distributor.

I need to display a form for each of those products and their corresp

2条回答
  •  有刺的猬
    2021-01-20 21:47

    You can use itertools to combine the two:

    from itertools import chain
    result_list = list(chain(page_list, article_list, post_list))
    

    Source: https://stackoverflow.com/a/434755/3279262

提交回复
热议问题