Reputation: 11
I have 2 class of model post
and comment
for loops in my template like this
I have a for loop like this
{% for post in posts %}
{% endfor %}
and I want to make filter like this Comment.objects.filter(post=post.id)
in my for loop and get some value
how to write it properly?
Upvotes: 0
Views: 203
Reputation: 903
{% for post in posts %}
{% for comment in post.comments.all %}
{{ comment }}
{% endfor %}
{% endfor %}
Upvotes: 2