I'm trying to download a file from a local directory in a Django template, but when I click and download it, I get a File Not Found error on my browser. As soon as I click download, the file explorer to choose the folder opens, but when I save the file I get that error. The path to the file I'm sure is right.
index.html
Download
Django doesn't serve static files by itself.
In order to create a file download link, you need to have a Django view that serves the static file. Refer here for more details https://djangoadventures.com/how-to-create-file-download-links-in-django/
Related
Can i use the url to a google drive folder as a download_path in selenium
for instance like this .Heroku error says file not found
mudopy.download_path(r"https://drive.google.com/drive/folders/1IPNuefeIXXCKm8Xxm3u1ekltxTF3dCT0")
According to the code of mudopy module, it saves the downloaded file into a local directory. So you can later upload that file to a google drive. Not sure if heroku allows to store something locally.
Moreover, the function mudopy.download_path does not download anything yet, but only creates a local file that stores the path to the folder where you want to save the downloaded files. And looks like Heroku does't even permit creating this file.
I created a Django project which I use in Apache server.
The project simply edits an .m3u file when you press a button on a page, and generates a new .m3u file. The script works as intended.
Can Django generate a download link automatically for this newly generated .m3u file? I understand from many tutorials that I need to edit the urls.py and view.py files, but I need it to be done automatically.
Or another option would be to make the file downloadable via Apache directly if something like this is possible.
is that is it possible Django can generate a download link automatically for this newly generated m3u file
Yes. I assume this is a static file located somewhere on the server. You can make file generator script/function return the location of generated file on server. The download URL can take location of this fileas a query parameter. You can make this file available using Django.
Or another option would be to make the file downloadable via apache diretly if something like this is possible.
Yes, you can. See Can you make a file downloadable through Apache?
I am using Django 2.0.2
I wish to be able to display HTML files that are in another location on disk. These are FastQC reports.
I don't want to copy them to templates or static folders and there is also no way to include them into DIRS.
Any suggestions on how to get that working?
I've written a scientific program in python which outputs a .png and a .pdf
I would like to execute this main.py file from a web interface, with a nice big button saying GO and then display the .png and download a .pdf
I'm using a Django framework to serve the page saying GO. How do i get it to:
run my main.py file?
return the .png file to html template?
download the file which is generated by the main.py script?
Thank you internet
This question is a little broad for a specific answer, but in general, one can:
Have the button access an API which will, on the server, in another thread, your main.py file.
Once the application is finished, move the generated files to a deterministic location that serves static files on your web server.
Provide the user a URL to the newly created file's location.
Have a cron job run to clear out old files in the static directory.
Most of my static files on my newly deployed Django website are working (CSS), but not the images. All the images are broken links for some reason and I cannot figure out why. I am serving my static files via Amazon AWS S3.
I believe all my settings are configured correctly as the collectstatic command works (and the css styling sheets are up on the web). What could be the problem?
It's probably impossible to give an accurate assessment with the limited info on your setup. If your css files are working what folder are they sitting in on your server?
Why not have images folder in the same directory and set that directory to your MEDIA_URL in your settings.py file?
In your browser check your images full path and compare that to your CSS files, where are they pointing, do you have a directory on your server where they are supposed to be? are you receiving an access denied if you try to directly put in that image url into your browser?