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
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
> 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
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
>
> 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
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
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):
7 matches
Mail list logo