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"
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 =
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)
3 matches
Mail list logo