Hi,

I would like to be able to select objects and order them by the count
of a related field

For example, I have 2 models:

class Author(models.Model)
    name = models.Charfield(max_length=20)

class Article(models.Model)
    author = models.ForeignKey(Author)
    content = models.TextField()


Let's say I have 3 authors:
1) John -- has 10 articles
2) Bob  -- has 20 articles
3) Lisa  -- has 30 articles

I would like to select authors and order by the number of articles
they have written:
Author.objects.all().order_by('article__count')

But this does not work.

Any suggestions?

Thanks,
R
--~--~---------~--~----~------------~-------~--~----~
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