【发布时间】:2018-11-18 07:04:16
【问题描述】:
我有一个这样的 API 的 json:
我的 views.py 看起来像这样:
def index(request):
movieData = requests.get('https://api.themoviedb.org/3/search/movie?query=Ishtar&api_key=....').json()
return render(request, 'dashboard/index.html', {'movieData': movieData})
我的 html 看起来像这样:
{% for item in movieData %}
<lu>
<li>
{{ item.results.id }}
</li>
</lu>
{% endfor %}
但是循环不起作用,它没有获取数据,这就是它的外观:
有人可以帮我吗?我正在学习。
我正在尝试在 json 结果中获取 4 部电影的 id
非常感谢
【问题讨论】:
-
这 4 个 id 在结果数组中吗?或者你想遍历结果数组?