开发者

Django template question?

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜