这是我的代码,谁调用错误:
{% extends "add_book_header.html" %}
{% block content %}
{% if books %}
<p>Results: {{ books|length }}</p>
{% for book in books %}
<div class="card h-100">
<img src={{book["volumeInfo"]["imageLinks"]["smallThumbnail"]}} class="card-img-top">
<div class="card-body">
<h5 class="card-title">{{ book["volumeInfo"]["title"]}}</h5>
<p class="card-text">descripthion</p>
<a href="#" class="btn btn-primary">link</a>
</div>
</div>
{% endfor %}
{% endif %}
{% endblock %}
这是书的结构
{
"kind": "books#volume",
"id": "NwxaDwAAQBAJ",
"etag": "guYzwBLXoHI",
"selfLink": "https://www.googleapis.com/books/v1/volumes/NwxaDwAAQBAJ",
"volumeInfo": {
"title": "Цельная жизнь. Главные навыки для достижения ваших целей",
"authors": [
"Джек Кэнфилд",
"Марк Виктор Хансен",
"Лес Хьюитт"
],
"publisher": "Litres",
"publishedDate": "2020-01-31",
"industryIdentifiers": [
{
"type": "ISBN_10",
"identifier": "5041133891",
},
{
"type": "ISBN_13",
"identifier": "9785041133894",
}
],
"readingModes": {
"text": true,
"image": true,
},
你可以相信我,所有的钥匙都是对的。这是我的错误:
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'imageLinks'
我已经为这个错误做了很多解决方案,我发现了。但什么都没奏效。包括它:
{% set img = book["volumeInfo"]["imageLinks"] %}
...
<img src={{img["smallThumbnail"]}} class="card-img-top">
第一个字符串效果很好,但第二个是调用错误。拜托我需要你的帮忙
沧海一幻觉
杨__羊羊
MMTTMM
相关分类