I am trying to build the search for a Django site I am building, and in that search, I am searching in 3 different models. And to get pagination on the search result list, I
You can use Union
qs = qs1.union(qs2, qs3)
But if you want to apply order_by
on the foreign models of the combined queryset.. then you need to Select them before hand this way.. otherwise it won't work
Example
qs = qs1.union(qs2.select_related("foreignModel"), qs3.select_related("foreignModel"))
qs.order_by("foreignModel__prop1")
where prop1
is a property in the foreign model