You cannot get a file outside of your project unless you symlink it inside the project. This is also a Very Bad Thing(TM) as it may allow attackers to request arbitrary files. What you should do instead is this: 1) Put Data/01/export.txt to the static/ folder inside your app (with the same folder structure if you need it that way) 2) Build the path to your file with /static/ as prefix, i.e. http://127.0.0.1/static/Data/01/export.txt
On May 2, 2017 3:44 PM, Sixtine Vernhes <[email protected]> wrote: > > This is in development. I try to send url of my file in views.py : > > return render(request, "export.html", {'out': urlOut}) > > and in my template I have the link : > > Lien du <a href="{{out}}"> fichier </a> > > but when I open it I have this link : > > http://127.0.0.1:8000/home/myuser/Data/01/export.txt > > and I want to have this to download the file : > /home/myuser/Data/01/export.txt > > Have you any ideas? > > (sorry i'm newbie in django ^^) > > Le mardi 2 mai 2017 14:04:05 UTC+2, Antonis Christofides a écrit : >> >> Is this in production or development? What is the url that doesn't work? >> What happens when you try the url? >> >> Regards, >> >> A. >> >> Antonis Christofides >> >> http://djangodeployment.com >> >> On 2017-05-02 11:28, Sixtine Vernhes wrote: >>> >>> Hi ! >>> >>> I try to create a link on Django who download a static csv file, but I have >>> no idea how to do. >>> In my settings.py : >>> >>> STATIC_URL = '/static/' >>> STATICFILES_DIRS = ( >>> os.path.join(BASE_DIR, "static/"), >>> ) >>> >>> and my file is in this directory >>> >>> Would anyone have an idea ? >>> >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send an >>> email to [email protected]. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/j5ftp2xrd2aps3c4mtn66umn.1493736693783%40email.android.com. For more options, visit https://groups.google.com/d/optout.

