Hello

First, I must recommend that you use django-taggit, simpletag or any
other tagging app, otherwise you'll just be reinventing the wheel.

As for your question, you should read the aggregation docs. I don't
have the link handy, but this should be correct:
http://django.me/aggregation

Sincerely,
Andre Terra

On 7/3/11, Jonas Geiregat <[email protected]> wrote:
> Hello,
>
> I have the following models
>
> class Book(models.Model):
>       author = models.ManyToManyField(Author)
>       pub_date = models.DateTimeField()
>       ...
>
> class Author(models.Model):
>       tag = models.ManyToManyField(Tag)
>
> class Tag(models.Model):
>       name = models.CharField(max_length=20)
>
> What I want to query for is:
>
> The most used Tags (and their count) for all books who's pub_date is greater
> then today.
>
> I can solve the last part
> Book.objects.filter(pub_date__gt=datetime.date.today())
>
> But how do I count all the tags for all these books ?
>
> Jonas Geiregat
> [email protected]
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
Sent from my mobile device

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to