I want to concatenate two queryset obtained from two different models and i can do it using itertools like this:
ci = ContributorImage.objects.all()
pf = Portfolio.objects.all()
cpf = itertools.chain(ci,pf)
But the real fix is paginating results.If i pass a iterator(cpf, or our concatenated queryset) to Paginator
function, p = Paginator(cpf, 10)
, it works as well but fails at retrieving first page page1 = p.page(1)
with an error which says:
TypeError: object of type 'itertools.chain' has no len()
What can i do in case like this ?