filter and count on multi-table inheritance?

1 view
Skip to first unread message

Gabriel Farrell

unread,
Dec 18, 2009, 4:18:38 PM12/18/09
to Django users
I have the following models:

class News(models.Model):
title = models.CharField(max_length=128)
author = models.ForeignKey(User, related_name='news')

class Report(News):
subtitle = models.CharField(max_length=128)
synopsis = models.TextField()

class Post(News):
body = models.TextField()


I have a page where I list authors, and would like to include a count
of Reports and Posts from each one. Is there a way to filter News for
Report or Post items? I would like to add to the NewsManager so that
the template could include something as simple as
{{ author.news.report_count }}.

Reply all
Reply to author
Forward
0 new messages