[Answered ]-Django, how to make a download button for a script displayed on the website

2👍

This is already documented in docs – https://docs.djangoproject.com/en/dev/ref/request-response/#telling-the-browser-to-treat-the-response-as-a-file-attachment

response = HttpResponse(my_data, content_type='text/x-python')
response['Content-Disposition'] = 'attachment; filename="foo.py"'

Leave a comment