开发者

Displaying image url from django template

开发者 https://www.devze.com 2023-04-05 08:00 出处:网络
this is a really basic question - I have a model called Book, which has an attribute imageURL (whic开发者_如何学Ch is a charfield).

this is a really basic question -

I have a model called Book, which has an attribute imageURL (whic开发者_如何学Ch is a charfield).

I have this template code -

<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" />

However, the str(book.imageURL) always returns an unicode value (because that's what Django models do?) - how can I get the string url so I can put it in here?

Thanks


The template code is invalid, try this:

<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" />
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号