[Fixed]-Django – Serve files for download

1👍

In your urls, you need to create something like:

url(r'^(?P<file_path>\w+)/(?P<original_filename>\w+)/$', views.doc_dwnldr, name='doc_dwnldr')

which will map to the function you have when the link is clicked in your template.

Then in your template, do something like:

<a href="{% url 'doc_dwnldr' file_path='file_path_variable_here', original_filename='filename_variable_here' %}">Download </a>
👤jape

Leave a comment