[Django]-Django concatenate two querysets for same model

3👍

You can try to do it like here:

https://stackoverflow.com/a/2176471/4971083

It’s the solution for ordering your records by specific value in Django.
You could order your records by distributor_name = ‘FirstDistributor’

p= Product.objects.filter(product__id=product_id).extra(
select={'is_top': " distributor__name='FirstDistributor'"})
p = p.extra(order_by = ['-is_top'])
👤koala

1👍

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

Leave a comment