django getting the absolute path of a FileField

前端 未结 2 696
灰色年华
灰色年华 2021-02-19 07:09

I am trying to retrieve the absolute path (starting with http://) while calling a FileField at the template.

How can I achieve this ?

ie: {{fl.uploadedfile

2条回答
  •  不要未来只要你来
    2021-02-19 08:11

    The Django File object provides several convenience functions/attributes, one of which is the URL associated with the file. In this case, as you pointed out, you're looking for the url attribute.

提交回复
热议问题