Re: A little help with a filter

2006-06-02 Thread Chris Moffitt
A perfect explanation > > s1 = set([obj.id for obj in > item1.sub_item_set.filter(options__name__exact="Small")]) > s2 = set([obj.id for obj in > item1.sub_item_set.filter(options__name__exact="Blue")]) > > smallAndBlueIDs = s1.intersection(s2) > smallAndBlueSubItems = Sub_Item.objects.in_bulk(lis

Re: A little help with a filter

2006-06-01 Thread DavidA
Chris, If I understand your problem, its that you want to do an "and" across multiple rows, which is not a simple query (and I'm not sure how to do in the model API). To be more clear, your Sub_Item table relates through a many-to-many relationship to ObjectItem so the SQL to get all Sub_Items wi

Re: A little help with a filter

2006-06-01 Thread Chris Moffitt
> Try going into the interactive interpretter (python manage.py shell) > and importing your models, then try: > > query=item1.sub_item_set.filter(options__name__exact="Small").filter(options__name__exact="Blue") > > then inspect the resulting SQL query components by executing: > > print query._ge

Re: A little help with a filter

2006-06-01 Thread wam
Chris Moffitt wrote: > If I try this: >item1.sub_item_set.filter(options__name__exact="Small").filter(options__name__exact="Blue") > I get an empty list. > > I've tried this using Q objects and some other things but I can't get it > to work. Anyone have ideas of what I'm doing wrong? > Try goin

Re: A little help with a filter

2006-06-01 Thread Chris Moffitt
> > Any chance that you're having a case problem? __exact is case > sensitive, while __iexact is case insensitive. > Thanks for the thought. I get the same behavior with iexact. If I run any of the 2 queries by themeselves, they return results. When chained together they do not. I also forgot

Re: A little help with a filter

2006-06-01 Thread Jay Parlar
On 6/2/06, Chris Moffitt <[EMAIL PROTECTED]> wrote: > > I feel like this should be simple but I'm struggling getting this to work > like I think it should. > > Here's the relevant model parts: > > class Item(models.Model): > category = models.ForeignKey(Category) > verbose_name = models.Ch

A little help with a filter

2006-06-01 Thread Chris Moffitt
I feel like this should be simple but I'm struggling getting this to work like I think it should. Here's the relevant model parts: class Item(models.Model): category = models.ForeignKey(Category) verbose_name = models.CharField("Full Name", maxlength=255) class OptionItem(models.Model):