Re: A Query question about Many-to-many relationships

2010-02-22 Thread Jason
Hi Atamert, Thank you so much! The following statement works! This is really simple but fantastic!!! Publication.objects.filter(article__in = article_qs).annotate(Count('article')) Sincerely, Jason -- You received this message because you are subscribed to the Google Groups "Django users"

Re: A Query question about Many-to-many relationships

2010-02-22 Thread Atamert Ölçgen
Hi Jason, On Monday 22 February 2010 09:57:18 Jason wrote: > If I already had a QuerySet of Article named articles, how to get a > QuerySet of Publication by these articles, You can use field lookup operator `in` like this: >>> Publication.objects.filter( >>> article_set__id__in =

A Query question about Many-to-many relationships

2010-02-21 Thread Jason
Dear All, Model source code: from django.db import models class Publication(models.Model): title = models.CharField(max_length=30) class Article(models.Model): headline = models.CharField(max_length=100) publications = models.ManyToManyField(Publication)