开发者

Displaying image url from django template

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜