Reputation: 215
I need to display all the videos within a certain playlist. I can display all the avaliable playlists by using this loop:
{% for p in playlists %}
{{ p.playlist.name }}
{% endfor %}
How can I display all the videos in each playlist too?
Upvotes: 0
Views: 55
Reputation: 42805
It's hard to say since you don't show your models, but something like this could work:
<ul>
{% for p in playlists %}
<li>{{ p.playlist.name }}
<ul>
{% for v in p.playlist.videos %}
<li>{{ v.name }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
</ul>
I'm assuming your videos have a ForeignKey(Playlist, related_name="videos")
field.
Upvotes: 1