hi Malcolm thanks a lot for your explanations. i am much more fluent with Python than SQL, anyway ;-)
do you happen to have a good link for a merge-sort-style technique at hand? btw: wrt. merging query sets, i tried this ModelA.objects.filter(parent=None) | ModelB.objects.filter(item=None) but this does work only with the same base model. even when using two different models that have the same parent model. thanks & cheers André > it does not seem to be possible to filter on the return value of a > > model's method, or is it? > > No, it isn't. Filtering and sorting are converted to SQL statements and > there's no way to write an SQL statement in this fashion. all right > are there alternative ways to achieve this? > > Do the final filtering/sorting in Python. Unless you are returning > hundreds of thousands of results, doing work in Python will be quite > fast and easy to understand in the code. > > So just run through each of your child models, extracting the > appropriate queryset for them and then merge those iterators (each > queryset is an iterator) to produce the final results. If ordering > matters, use a merge-sort-style technique to merge the iterators. If > ordering doesn't matter, use itertools.chain. > cool --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---

