JIoJIaJIu
JIoJIaJIu

Reputation: 75

multiple queryset

How I can use querySet interface for two and more models?
for example:

assortments = get_list_or_404(Assortment, [some_list]) #this is content_types of each models
category = [ assortment.type.model_class() for assortment in assortments ]
all_goods = map(lambda cl: cl.objects.filter(has_shop=True, **kwargs).distinct(), category)
all_goods = reduce(lambda l,l1: l.extend(l1) or l, all_goods, [])

but now i cant use querysets methods, like order_by, for example
how else can i get list of objects from different models?

Upvotes: 0

Views: 298

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599600

You can't. A queryset is an ordered collection of instances of a single model type. There's no such thing as a queryset of multiple models.

Upvotes: 1

Related Questions