Home > OS >  Use filename insted of 'Download'
Use filename insted of 'Download'

Time:02-15

On my Django page I have a paragraph to download attached files:

{% for i in post.file_set.all %}<p ><strong>Attachment {{ forloop.counter }}: </strong><a href="{{i.file.url}}" >Download</a></p>{% endfor %}

How can I show File name insted of word 'Download'. Users don't know which file is which when downloading, in case of many files. Also, if extension is possible.

So, insted of:

Attachment: Download

I would like to have:

Attachment: image.png

CodePudding user response:

Just replace Download with {{i.file.name}}

{% for i in post.file_set.all %}<p ><strong>Attachment {{ forloop.counter }}: </strong><a href="{{i.file.url}}" >{{i.file.name}}</a></p>{% endfor %}
  • Related