On Sun, 2008-07-20 at 10:28 +0200, Andre Meyer wrote:
> hi all
> 
> 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.

>  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.

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