I can't post image because I'm new so here's a link of what I want.
So, I have the model on the left and I want the view on the right.
As of now, I'm looping over every thread I'm interested in. Template code:
{% for thread in threadlist %}
{% for post in thread.postlist %}
...
Model code:
class Thread (models.Model):
...
def postlist(self):
posts = list(self.post_set.all())
return [posts.pop(0)] + posts[-2:]
There must be a way to do this with less queries by joining columns or something. I'm pretty new to Python/Django and I don't really know how to do this.