On Wed, 2008-11-19 at 11:04 -0800, Luke Seelenbinder wrote:
> the models are:
> 
> class Word(models.Model):
>    ... some stuff...
> 
>    class Meta:
>        abstract=True
> class Noun(Word):
>     .. some stuff ..
> class Verb(Word):
>   ... some stuff ...
> 
> code:
> 
> nouns= Noun.objects.all()
> verbs=Verb.objects.all()
> 
> words = verbs | nouns
> 
> I get an error saying: "Cannot combine queries on two different base
> models."
> is there anyway to accomplish this,

Not at the SQL level. Doing a union of two completely distinct result
sets like this is not really a common enough operation to warrant to
extra complexity in Django's ORM. Realise that, in the general case, the
two querysets could have completely different sets of columns and
everything.

The simplest way to achieve the same effect is order each Queryset
individually. Then you'll have two Python iterators (a queryset is an
iterator) that are sorted appropriately and you just need to merge the
results together into a final sorted iterator. In other words, you're
doing a merge (or tape) sort where you've already sorted the individual
sub-piles.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to