Django Get ImageField Path

拜拜、爱过 提交于 2019-12-07 01:34:05

问题


models

image_url = models.ImageField(upload_to="uploads/shows",blank=True,null=True)

I am having image_url which I need to parse it using JSON object to my android application. I only need the URL of the image(absolute/relative).

I have tried

image_url=myObj.file.url
image_url=myObj.image_url

回答1:


The correct working solution as provided by @alecxe is

image_url =myObj.image_url.url


来源:https://stackoverflow.com/questions/18740651/django-get-imagefield-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!