Solved (in Django 1.1):
tags = Tag.objects.annotate(num_pages=Count('page')).filter
(num_pages__gt=0)
On 9 Jan., 19:50, janedenone wrote:
> I defined two models (Tag and Page), where the Page model links to the
> Tag model:
>
> tags = models.ManyToManyField(Tag,
I defined two models (Tag and Page), where the Page model links to the
Tag model:
tags = models.ManyToManyField(Tag, blank=True)
For a single tag, I can refer to the pages linked to that tag like so:
for page in tag.page_set:
...
results = tag.page_set.count()
But I cannot find a way to
2 matches
Mail list logo