Thanks,

 

I’d like to use the all – filter, but as this is going to be used in a search functionality where the user determines what filters he/she wants, it might easily return 0 to 10 000+, depending on the other filters, more results that is necessary. Not to mention, I would need to manually sort and limit the results.

 

Hand writing the SQL might work, though, I would need to hand-write the whole query, including other filters, and turn the results manually as Color objects. How exactly would “where/tables clauses in a filter” you mentioned work?

 

- Mikko Nylén

 

From: django-users@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Russell Keith-Magee
Sent: 29. kesäkuuta 2006 5:22
To: django-users@googlegroups.com
Subject: Re: Exclusion by a many-to-many field to self

 

 

On 6/28/06, Mikko Nylén <[EMAIL PROTECTED] > wrote:

I've tried this:
Color.objects.exclude(similar_colors__the_color__startswith="..."), and it
almost works. However, the problem is, it doesn't give the Colors which
don't have any Colors in similar_colors. I need to get these as well.


Interesting... this could be interpreted as a bug in exclude(). It might be worth checking to see if this has been identified before, and if not, raising this as a bug. Sounds like it could be a problem with a join that should be OUTER, but is LEFT INNER (or some such).
 

In other words, what I want is (if this syntax would be possible):
Color.objects.all() -
Color.objects.filter(similar_colors__the_color__startswith="..."), as the
filter() gives all those objects I don't want to get included.


exclude() would have been my suggestion. You could try hand writing the SQL, or using where/tables clauses in a filter to build a search that does what you want; or, depending on how large you are expecting your result set to be, actually do the subtraction you mention (all - filter).

Russ Magee %-)



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

Reply via email to