In my specific case, I have two kinds of "messages" that I need to retrive and paginate.
Let's omit the details, and just say that the first kind is in a model called Msg1 and the other is called Msg2
The fields of these two models are completely different, the only fields that are common to the two models are "date" and "title" (and of course, id).
I can get Msg1.objects.all()
and Msg2.objects.all()
but can I combine these two queries into one query, sort it by date, and paginate it?
I need to preserve the lazy nature of the query.
The trivial solution is to list(query)
both queries and combine them in a python list. but this is inefficient for obvious reasons.
I looked through the django references on models and dp-api, but it doesn't seem that there is a way to combine queries of different models/tables into one.