Hello everyone, I am trying to create a query that includes all of the ‘Video’ objects that are inside a list inside my view function.
The following is the view function:
def BuenosAiresVideos(request):
videoList = ["Buenos Aires", "Caminito",
"Buenos Aires Drone Footage", "Recoleta Cemetery"]
# videos = Video.objects.filter(title__in=videoList)
videos = Video.objects.all()
context = {
'videos': videos,
}
return render(request, 'map_app/buenos-aires-videos.html', context)
For some reason when I attempt to grab all of the video objects with videos = Video.objects.all(), this statement only grabs the video titled “Buenos Aires”.
As a result, the following is what I am seeing inside the HTML file:
The following is the HTML file:
{% load embed_video_tags %}
<!DOCTYPE html>
<html>
<body>
{% block content %}
<h1 class="mb-5">Buenos Aires Travel Videos</A></h1>
<div class="d-flex flex-wrap">
{% for item in videos %}
<div class="px-3 mb-5">
<!-- {% if item.title == 'Buenos Aires' %} -->
{% video item.url '426x240' %}
<div class="d-flex justify-content-start">
{{ item.title }}
</div>
<!-- {% endif %} -->
</div>
{% endfor %}
</div>
{% endblock %}
</body>
</html>
The others videos appear to be inside the database when I grab them in the python shell:
Please help me understand why the only video displaying is “Buenos Aires”. Thank you.