Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 显示来自django模板的图像url_Html_Django_Django Templates - Fatal编程技术网

Html 显示来自django模板的图像url

Html 显示来自django模板的图像url,html,django,django-templates,Html,Django,Django Templates,这是一个非常基本的问题- 我有一个名为Book的模型,它有一个属性imageURL(是charfield) 我有这个模板代码- <text class= "text" id = "bookTitle">{{ book.title|safe }}</text><br/> <text class= "text" id= "bookAuthor">by {{ book.author|safe }}</text>

这是一个非常基本的问题-

我有一个名为Book的模型,它有一个属性imageURL(是charfield)

我有这个模板代码-

<text class= "text" id = "bookTitle">{{ book.title|safe }}</text><br/>
                <text class= "text" id= "bookAuthor">by {{ book.author|safe }}</text><br/>
                <img src= str(book.imageURL) class = "result" />
{{book.title | safe}}
作者{book.author | safe}}
但是,str(book.imageURL)总是返回一个unicode值(因为Django模型就是这样做的?)-我如何获得字符串url以便将其放在这里


谢谢,模板代码无效,请尝试以下操作:

<text class= "text" id = "bookTitle">{{ book.title|safe }}</text><br/>
                <text class= "text" id= "bookAuthor">by {{ book.author|safe }}</text><br/>
                <img src="{{ book.imageURL }}" class = "result" />
{{book.title | safe}}
作者{book.author | safe}}
试试这个: