0

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?

1
  • ok. and what is the best way to sorted my list by prices for example? Commented Nov 30, 2010 at 13:51

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

+1, and it's very tightly-coupled to the Model concept as well! code.djangoproject.com/browser/django/trunk/django/db/models/… Can't even manually create your own generic QuerySet to handle this unless you boil it down to one common model.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.