I am trying to search api data through a search bar then render it to another template and I keep getting this error. I am not sure how to fix it. I have done some research and looked at the docs but haven’t been able to correct the issue. I am still new to coding and to Django so any help would be appreciated. Here is my api call
def search_results(request):
searched = request.GET.get('searched', '')
if searched:
# Perform the search
key = config('API_KEY')
youtube = build('youtube', 'v3', developerKey=key)
request = youtube.search().list(
part="snippet",
maxResults=5,
q=searched,
order="date",
type='video'
)
results = request.execute()
print(results)
return render(request, 'search/results.html', {'results': results})
else:
return render(request, 'search/results.html', {'results': {}})
```
Here is my template I want to render data to
{% extends ‘base.html’ %}
{% block content %}
{% for key, value in results.items %}
{% endfor %}
{% endblock %}
My API Data structure
