Re: How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-17 Thread Andréas Kühne
If you use a windows.location solution, you will get the native solution for downloading files in the browser - which usually is to download the file to the downloads location (if you use attachment=True). I would prefer that than to having to create the file and link to it, or to save it via JS

Re: How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-17 Thread Yavin Aalto Arba
will work with window.location= On Saturday, November 17, 2018 at 5:55:18 PM UTC+2, Joel wrote: > > Yes. But it's not usable when we're using JavaScript to fetch the url. > > On Sat, 17 Nov, 2018, 9:20 PM Jason > wrote: > >> oh, I didn't know that was a thing. TIL. >> >> >>

Re: How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-17 Thread Joel
Yes. But it's not usable when we're using JavaScript to fetch the url. On Sat, 17 Nov, 2018, 9:20 PM Jason oh, I didn't know that was a thing. TIL. > > > https://docs.djangoproject.com/en/2.1/ref/request-response/#django.http.FileResponse > > note the bit about as_attachment setting content

Re: How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-17 Thread Jason
oh, I didn't know that was a thing. TIL. https://docs.djangoproject.com/en/2.1/ref/request-response/#django.http.FileResponse note the bit about as_attachment setting content disposition -- You received this message because you are subscribed to the Google Groups "Django users" group. To

Re: How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-17 Thread Joel Mathew
Where? Sincerely yours, Joel G Mathew On Sat, 17 Nov 2018 at 20:50, Yavin Aalto Arba wrote: > did you try to set "as_attachment=True" ? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop

Re: How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-17 Thread Yavin Aalto Arba
did you try to set "as_attachment=True" ? -- 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 django-users+unsubscr...@googlegroups.com. To post to this group, send

Re: How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-17 Thread Jason
not a bad solution, but you could most likely make the link generator/decoder work in your view handler rather than needing to hit the database. That would prevent the necessity of some method to clean up the db of old temp links that are no longer valid. On Saturday, November 17, 2018 at

Re: How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-17 Thread Joel Mathew
Hi Jason, Thank you for responding. I solved this by implementing a temporary link system in my model. This would generate a unique key which points to a foreign key which references the data I want. When the url with this foreign key is clicked, the pdf is generated on the fly and presented as a

Re: How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-17 Thread Jason
check out https://stackoverflow.com/questions/4545311/download-a-file-by-jquery-ajax -- 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

How to download a file when a django function is called by javascript instead of navigation to the url?

2018-11-16 Thread Joel Mathew
I have a page where several buttons process different functions like sending a user sms (via API), sends an file by email, or downloads a PDF file. Button actions dont use forms, but uses ajax requests via javascript. I used to create a pdf file using javascript (jspdf), but have written code