1👍
✅
In your template loop, you’ve defined the object as choice
. Just refer to it that way rather than using rockvids
. See below.
{% for choice in rockinfo.rockvids_set.all %}
<img id="hide" src="http://img.youtube.com/vi/{{ choice.vid_id }}/hqdefault.jpg" data-video="https://www.youtube.com/embed/{{ choice.vid_id }}?autoplay=1" width="480" height="300"/>
{% endfor %}
Since you’ll have multiple images, you probably want to change id="hide"
to class="hide"
as well, since there should only be one element with a given id
on a page.
Source:stackexchange.com