saxix/django-admin-extra-buttons

Add the possibility to download a file from a button handler

sronveaux opened this issue · 2 comments

Hello,

I have a case where I'd like a button to download a file by returning a FileResponse. However, the current code checks if something else than a HttpResponse is given and Redirects in that case :

if not isinstance(ret, HttpResponse):
return HttpResponseRedirectToReferrer(request)
return ret

I made a quick and dirty patch locally to test replacing line 52 with if not isinstance(ret, (FileResponse, HttpResponse)): and this did the trick for me.

I wondered if there was something else I wasn't aware of and if there was a reason not to give the opportunity to send back files from your excellent Django app. Otherwise, would you mind if I open a PR with this modification ?

Thanks for the excellent work,
Cheers

Sébastien

Hello,

I have exactly the same issue with StreamingHttpResponse. In my case, I need a button to download a huge zip file which needs to be streamed to the client.

Can you please add support for it as well?

Thanks!
Adrian

Same here, I need to return a FileResponse. Happy to contribute to the PR if that's still on the table.