Hugo Osvaldo Barrera
unread,Aug 21, 2015, 5:06:43 AM8/21/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hi all,
Let's assume I've the classic blog post with multiple comments model.
I'm trying to get a list of posts each annotated with its last comment
(or at least a single field from it).
The closest I've gotten is via:
Post.objects.annotate(last_comment=F('comment__text'))
But this just returns the body for the first commend, and I explicitly
want the last.
Am I missing something pretty obvious? Or is there some smart way of
doing this that I'm failing to see?
Thanks,
--
Hugo Osvaldo Barrera