> Something like this:
> Query = Comments.objects.all().sort_by("submit_date")[:5]Without having the models, it's a little difficult to judge what the OP is after. However, the difference is that your version gets you the top 5 *comments*. The OP appears to want the top 5 unique "object_pk" fields associated with those comments. If that object_pk were a unique/primary key on django_comments, your query would work. However, since it doesn't appear to have a uniqueness-constraint (from my look at the source-code), it looks like if the top 5 comments were all on the same object, you'd get different results -- your query would pull back those top 5 comments (and the .values().distinct() would bring back the one object) whereas the OPs code would find the top 5 commented-on things. I can't think there's a way to coerce the ORM to produce the OP's desired query, but Django lets you drop to raw SQL pretty easily, so it shouldn't be a big deal. -tkc --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

