Matthew, Thanks for the info.
On Thu, 20 Jul 2006 10:05:43 +1000, Matthew Flanagan wrote: >> In [73]:Image.objects.filter(tags__id=1).filter(tags__id=2) >> Out[73]:[] >> > > I think you want to use: > > Image.objects.filter(tags__id__in=[1,2]).distinct() Alas, this returns all the images with tag1 OR tag2. I'm looking for images with tag1 AND tag2. Thanks Neilen > > >> However, I know images with both of those tags exist, eg: >> >> In [73]:i = Image.objects.filter(tags__id=1)[0] >> >> In [74]:i >> Out[74]:<Image: 2004-09-23++14-10-03_++_dsc_5994.jpg> >> >> In [75]:[tag.id for tag in i.tags.all()] >> Out[75]:[1, 2, 3, 17, 170, 259, 362, 387, 414, 647, 681, 810] >> >> How can I find the image(s) with a given set of tags? >> >> Thanks >> Neilen >> >> -- >> you know its kind of tragic >> we live in the new world >> but we've lost the magic >> -- Battery 9 (www.battery9.co.za) >> >> >> > >> > > -- you know its kind of tragic we live in the new world but we've lost the magic -- Battery 9 (www.battery9.co.za) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---