Join Multiple Querysets From Different Base Models Django Join Multiple Querysets From Different Base Models Django django django

Join Multiple Querysets From Different Base Models Django


from itertools import chainreport = chain(ledger, journal)

Itertools for the win!

If you want to do an Union, you should convert these querysets into python set objects.

If it is possible to filter the queryset itself rightly, you should really do that!


Use itertools.chain:

from itertools import chainreport = list(chain(ledger, journal))

Note: you need to turn the resulting object into a list for Django to be able to process it.