37👍
✅
There’s a relevant example in the docs:
from django.http import HttpResponse
def some_view(request):
# Create the HttpResponse object with the appropriate headers.
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename="somefilename.pdf"'
return response
Source:stackexchange.com