L
L
Larisa .•º2017-01-12 17:24:49
Django
Larisa .•º, 2017-01-12 17:24:49

How to generate a link to download a file?

There is a view - which generates a file in the reports folder.
How to generate a link to download the generated file, ?
If it's just along the path: "/reports/rep.doc", then it says that the given url was not found :( (I don't understand how to form it correctly? ) :(((

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Max, 2017-01-12
@barolina

Add this directory to urls.py. In the following way:

import os
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    ...
]

urlpatterns += static('/reports/', document_root=os.path.join(settings.BASE_DIR, 'reports'))

You can read more here .

A
alex maslakoff, 2017-01-12
@teke_teke

add folder to routes

T
ThunderCat, 2017-01-12
@ThunderCat

perhaps a rule is written in .htaccess - do not give any files, respectively, it will be necessary to introduce an exception.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question