Active 1 year, 8 months ago. Viewed 9k times. Improve this question. Jens Testing man Testing man 10 10 silver badges 25 25 bronze badges. Add a comment. Active Oldest Votes. You need to read that file. Serve it using HttpResponse along with proper content type.
Improve this answer. Farid Chowdhury Farid Chowdhury 1, 16 16 silver badges 16 16 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. How are you using 'response' var in view? I don't return response so that i can use my template. If i just make "return response" i can download the file directly without having my template so my button. Add a comment.
Active Oldest Votes. How about registering the view in urls. First, you can drop the home. In urls. Improve this answer. Victor T Victor T 3 3 silver badges 13 13 bronze badges.
I have a similar view in a Django project, and I'm quoting the filename as well, but I'm not sure if that is necessary EDIT: also, there is a typo in "attachment", remove the extra "e" and see if that helps. Bob Vork Bob Vork 2, 24 24 silver badges 31 31 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. HTML :- Here in this file we had created a form with method equals to post and specify the action or the URL to relocate after the user clicks on the submit button.
HTML:- Here, this file is loaded when the user clicks the submit button in the index. Here we passed all the objects of our model which specifies the title and URL of the uploaded file.
If you focus on the anchor tag, I had passed the URL of the file in HREF and specified the keyword download inside it, so that when the user clicks the link instead of redirecting to a new page, it will download the file.
I hope this blog will be useful for you and helps you to understand each and every step. Hope all your doubts get cleared. Best of Luck and Thank you. Downloaded File after clicking the above link.
0コメント